Documentation ¶
Index ¶
Constants ¶
const ( BadRequest = "bad_request" AccessDenied = "access_denied" NotFound = "not_found" RouteNotFound = "route_not_found" MethodNotAllowed = "method_not_allowed" Unknown = "unknown" NoLongerSupported = "no_longer_supported" TooManyRequests = "too_many_requests" ContextCanceled = "context_canceled" EOF = "eof" UnexpectedEOF = "unexpected_eof" RequestTimeout = "request_timeout" ThirdPartyTimeout = "third_party_timeout" CoercionError = "unable_to_coerce_error" )
errors that are expected to be common across services
Variables ¶
This section is empty.
Functions ¶
func CoerceThirdPartyTimeout ¶
func WrapIfNotCher ¶
WrapIfNotCher will not wrap the error if it is any cher except unknown.
Unless you don't know the codes you could get back, you should use WrapIfNotCherCodes.
Types ¶
type E ¶
type E struct { Code string `json:"code"` Meta M `json:"meta,omitempty"` Reasons []E `json:"reasons,omitempty"` }
E implements the official Cuvva Error structure
func Coerce ¶
func Coerce(v interface{}) E
Coerce attempts to coerce a Cuvva Error out of any object. - `E` types are just returned as-is - strings are taken as the Code for an E object - bytes are unmarshaled from JSON to an E object - types implementing the `error` interface to an E object with the error as a reason
func (E) StatusCode ¶
StatusCode returns the HTTP Status Code associated with the current error code. Defaults to 400 Bad Request because if something's explicitly handled with Cher, it is considered "by design" and not worthy of a 500, which will alert.