Documentation
¶
Overview ¶
Package apperr holds the error kinds every layer shares. The store raises ErrNotFound and ErrAlreadyExists, the service layer wraps them or raises its own rejections, and the HTTP layer maps them to statuses — all against these same values, so a handler can tell "not found" from "forbidden" without importing the store, and there is exactly one ErrAlreadyExists.
Index ¶
- Variables
- func Conflict(format string, args ...any) error
- func Forbidden(format string, args ...any) error
- func Invalid(format string, args ...any) error
- func Message(err, kind error) (string, bool)
- func NotFound(format string, args ...any) error
- func Reject(kind error, format string, args ...any) error
- type Rejection
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound: the thing asked for does not exist. ErrNotFound = errors.New("not found") // ErrAlreadyExists: a uniqueness rule refused the write (a duplicate // name, slug, key or ID). ErrAlreadyExists = errors.New("already exists") // ErrForbidden: the thing exists, but the caller may not do this to it. ErrForbidden = errors.New("forbidden") // ErrValidation: the caller's input breaks a rule (a bound, a required // field, an unknown value). ErrValidation = errors.New("invalid input") // ErrConflict: the request is fine, but the thing's current state refuses // it (still in use, changed meanwhile). ErrConflict = errors.New("conflict") )
Functions ¶
func Message ¶
Message returns the user-facing text of err's Rejection of the given kind, if it carries one.