Documentation
¶
Overview ¶
Package apperr defines the domain error vocabulary shared by every service. Services return these; the single translation point httpx.RenderError maps them to RFC 9457 problem+json. Keeping them here (not in each service package) lets httpx translate without importing the whole service tree.
Index ¶
Constants ¶
const ( ErrNotFound = sentinel("not found") ErrForbidden = sentinel("forbidden") ErrConflict = sentinel("conflict") ErrUnauthenticated = sentinel("unauthenticated") ErrBadRequest = sentinel("bad request") ErrNotImplemented = sentinel("not implemented") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conflict ¶
type Conflict struct{ Detail string }
Conflict carries a specific human detail (e.g. "team name already taken").
type Forbidden ¶
type Forbidden struct{ Detail string }
Forbidden carries a specific human detail (e.g. "event is not running"). It reports Is(ErrForbidden) so callers can check the sentinel.
func Forbiddenf ¶
type NotFound ¶
type NotFound struct{ Detail string }
NotFound carries a specific detail; renders 404.
type NotImplemented ¶
type NotImplemented struct{ Detail string }
NotImplemented renders 501; used for endpoints whose contract exists but whose implementation is not wired yet.
func (*NotImplemented) Error ¶
func (e *NotImplemented) Error() string
func (*NotImplemented) Is ¶
func (e *NotImplemented) Is(t error) bool
type RateLimited ¶
RateLimited signals a 429 with a Retry-After. Scope labels the metric.
func (*RateLimited) Error ¶
func (e *RateLimited) Error() string
type Unavailable ¶
type Unavailable struct {
}
Unavailable carries a specific detail; renders 503 (e.g. runtime unreachable). RetryAfter, when > 0, is surfaced as a Retry-After header — used for load-shed backpressure (e.g. the argon2id hashing gate).
func (*Unavailable) Error ¶
func (e *Unavailable) Error() string
func (*Unavailable) Is ¶
func (e *Unavailable) Is(t error) bool
type Validation ¶
Validation is a set of field-level failures rendered as a 422 with an errors map.
func NewValidation ¶
func NewValidation() *Validation
NewValidation builds an empty Validation error.
func (*Validation) Add ¶
func (v *Validation) Add(field, msg string)
Add appends a message for a field.
func (*Validation) Error ¶
func (v *Validation) Error() string
func (*Validation) HasErrors ¶
func (v *Validation) HasErrors() bool
HasErrors reports whether any field failed.
func (*Validation) OrNil ¶
func (v *Validation) OrNil() error
OrNil returns nil when there are no field errors, else the receiver.