Documentation
¶
Index ¶
- Constants
- func ErrDBConnection(inner error) error
- func ErrDBQuery(op, table string, inner error) error
- func ErrForbidden(resource string) error
- func ErrInternal(inner error) error
- func ErrNATSPublish(subject string, inner error) error
- func ErrNotFound(resource string, id any) error
- func ErrRateLimited(retryAfter int) error
- func ErrStatus(status int, msg string, kv ...any) error
- func ErrTimeout(operation string) error
- func ErrUnauthorized(reason string) error
- func ErrValidation(field, constraint string, val any) error
- func WriteProblem(c fiber.Ctx, status int, code, detail string) error
- func WriteProblemWith(c fiber.Ctx, status int, code, detail string, extra map[string]any) error
- type Problem
Constants ¶
const ( ErrCodeNotFound = "ERR_NOT_FOUND" ErrCodeValidation = "ERR_VALIDATION" ErrCodeForbidden = "ERR_FORBIDDEN" ErrCodeRateLimited = "ERR_RATE_LIMITED" ErrCodeConflict = "ERR_CONFLICT" ErrCodeTimeout = "ERR_TIMEOUT" ErrCodeDBConnection = "ERR_DB_CONNECTION" ErrCodeDBQuery = "ERR_DB_QUERY" ErrCodeNATS = "ERR_NATS" ErrCodeInternal = "ERR_INTERNAL" )
Variables ¶
This section is empty.
Functions ¶
func ErrDBConnection ¶
func ErrDBQuery ¶
func ErrForbidden ¶
func ErrInternal ¶
func ErrNATSPublish ¶
func ErrNotFound ¶
func ErrRateLimited ¶
func ErrTimeout ¶
func ErrUnauthorized ¶
func ErrValidation ¶
func WriteProblem ¶ added in v0.34.1
WriteProblem answers with an RFC 9457 problem document. Middleware and entry handlers that must answer directly (not through the server error handler) use it so every error shares one shape. The type is "about:blank", the standard default when no problem registry is configured.
func WriteProblemWith ¶ added in v0.34.1
WriteProblemWith is WriteProblem plus extra extension members (the RFC allows them). Used when the error carries structured data, like the failing fields of an input validation.
Types ¶
type Problem ¶ added in v0.34.1
type Problem struct {
// Type identifies the problem type ("about:blank", the RFC default, when
// the writer has no registry base).
Type string `json:"type"`
// Title is the short summary of the type (the HTTP status phrase).
Title string `json:"title"`
// Status repeats the HTTP status code in the body, per the RFC.
Status int `json:"status"`
// Detail explains this occurrence.
Detail string `json:"detail,omitempty"`
// Instance identifies this occurrence (the request path).
Instance string `json:"instance,omitempty"`
// Code is the machine-readable error code (extension).
Code string `json:"code,omitempty"`
}
Problem is an RFC 9457 (Problem Details for HTTP APIs) document: the error body every service answers with, served as application/problem+json.
`code` is a registered extension carrying the machine-readable error code; a client that only knows the standard ignores it.