Documentation
¶
Overview ¶
Package fault defines stable application errors without exposing internal causes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Category ¶
type Category string
Category is the class of an Error; it selects the default HTTP status.
const ( CategoryInvalid Category = "invalid" CategoryForbidden Category = "forbidden" CategoryNotFound Category = "not_found" CategoryConflict Category = "conflict" CategoryRateLimited Category = "rate_limited" CategoryInternal Category = "internal" )
The categories of Error and their default HTTP statuses: 400, 401, 403, 404, 409, 503, 429 and 500.
type Error ¶
type Error struct {
Code string
Message string
Category Category
Cause error
Metadata map[string]string
Retryable bool
HTTPStatus int
}
Error is a stable application error: a machine-readable Code and a safe Message for clients, with an optional Cause and Metadata that stay internal.
func (*Error) Is ¶
Is matches another *Error with the same Code, so errors.Is recognizes a sentinel even after WithCause or Metadata produced a copy of it.
Click to show internal directories.
Click to hide internal directories.