Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Separator = " »» "
Separator defines the string used to separate nested errors.
Functions ¶
func As ¶
As calls stdlib errors.As to find the first error in err's chain that matches target, and if so, sets target to that error value and returns true.
func E ¶
func E(args ...interface{}) error
E builds an error value from its arguments. There must be at least one argument or E panics. The type of each argument determines its meaning. If more than one argument of a given type is presented, only the last one is recorded.
The types are:
string The HTTP message for the API user. errors.Kind The class of error, such as permission failure. error The underlying error that triggered this one.
If the error is printed, only those items that have been set to non-zero values will appear in the result.
If Kind is not specified or Other, we set it to the Kind of the underlying error.
func IsKind ¶
IsKind reports whether err is an *Error of the given Kind. If err is nil then Is returns false.
func ToHTTPResponse ¶
ToHTTPResponse creates a string to be used for HTTP response by chaining the underlying application errors HTTPMessage.
func ToHTTPStatus ¶
ToHTTPStatus converts an error to an HTTP status code.
Types ¶
type Error ¶
type Error struct { // application specific fields. HTTPMessage string // logical operation and nested error. Kind Kind Err error // contains filtered or unexported fields }
Error defines a standard application error.
type Kind ¶
type Kind int
Kind defines the error type this is, mostly for use by routers that must set different response status depending on the error.
const ( Other Kind = iota // Unclassified error BadRequest // Bad Request (400) Forbidden // Forbidden (403) NotFound // Not found (404) Conflict // Conflict (409) Gone // Gone (410) Unprocessable // Unprocessable, invalid request data (422) Internal // Internal server error (500) BadGateway // Bad gateway (502) )
Kinds types.