Documentation
¶
Index ¶
Constants ¶
const ( CodeNotFound = iota + 1 CodeDuplicated CodeLimit CodeInvalid CodePayment CodeForbidden CodeStore CodeNotImplemented CodeConflict CodeLocked CodeInternal CodeUnprocessable CodeTooManyRequests )
The kinds of failure an Error's Code names. Every layer whose errors can reach the API uses these, so a kind answers with the same HTTP status whichever layer raised it.
Variables ¶
This section is empty.
Functions ¶
func HTTPStatus ¶ added in v0.31.0
HTTPStatus returns the status the API answers an error of code with. CodeStore, CodeInternal and a code outside the kinds above answer 500.
func WithData ¶
WithData returns the Error in parent's chain with data as its Data. A nil parent returns nil, and a parent with no Error in its chain comes back unchanged.
func Wrap ¶
Wrap wraps an error with another error.
It is a interface for errors.Join. Check errors.Join for more information.
Types ¶
type Data ¶
type Data any
Data is a custom type to carry error's metadata. It can be any data type, but a struct is recommended due its fine control on JSON marshalling for each field.
type Error ¶
Error is a custom error that carry attributes to specify error's message, resource, layer, code and data.
type InvalidFields ¶ added in v0.31.0
InvalidFields is the Data of an error that names the request fields at fault and why, so a client can mark each one rather than show one message for the whole request.