Documentation ¶
Overview ¶
Package response provides the response handling logic for responses and any errors returned by the Paddle API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrErrorHandlerCallExpected = errors.New("error handler should be called, this response should not be handled here")
ErrErrorHandlerCallExpected should never be returned, it indicates that the error handling logic has failed.
var ErrUnexpectedResponse = errors.New("found nil paddle.Error when one was expected")
ErrUnexpectedResponse is returned when an paddle.Error was expected, but instead received nil.
Functions ¶
func Handle ¶
Handle handles the response from the Paddle API. The dst field is a response which will be decoded from the response body. The dst field should be given as a pointer. If the dst field is nil, no response body will be decoded. It is expected that any error handling logic is done before calling this function, and that this is only for handling of successful responses.
func HandleError ¶
HandleError handles the error response from the Paddle API. This will handle cases where the response is the standard error response type from the API, and will return the decoded paddleerr.Error. If the response is not valid, a response.Error will be returned.
Types ¶
type Error ¶
type Error struct { Method string Path string StatusCode int ResponseBody []byte // contains filtered or unexported fields }
Error contains the details of a non-expected error when making a request to the Paddle API. This is not to be confused with the public `paddleerr.Error` type. These are returned in cases of non-expected errors, such as decoding, timeouts, malformed response bodies, etc. The cause of the error can be inspected using errors.Is.
type Meta ¶
type Meta struct { RequestID string `json:"request_id"` Pagination *Pagination `json:"pagination"` }
Meta represents the metadata returned by the Paddle API.