apperr

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package apperr holds the cross-cutting sentinel errors, their detail-wrapper, and the HTTP status mapping. It is a leaf package (no airlock imports) so the authorization layer (authz) and the service layer can both return the same sentinels without an import cycle — service re-exports these as service.ErrX aliases.

Methods return a sentinel that HTTPStatus translates to a status code at the HTTP boundary. User-facing message strings are chosen per endpoint by the handler — lower layers don't synthesize prose.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnauthorized — caller has no credentials. Maps to 401.
	ErrUnauthorized = errors.New("unauthorized")

	// ErrForbidden — caller is authenticated but lacks the required
	// agent-access level or tenant role. Maps to 403.
	ErrForbidden = errors.New("forbidden")

	// ErrNotFound — target row does not exist. Maps to 404.
	ErrNotFound = errors.New("not found")

	// ErrConflict — write rejected by a uniqueness or state constraint
	// (already exists, wrong-state transition, etc.). Maps to 409.
	ErrConflict = errors.New("conflict")

	// ErrInvalidInput — caller-supplied data is malformed or fails a
	// service-level invariant. Maps to 400. HTTP-level parse errors
	// (bad JSON, bad UUID in URL) stay in the handler.
	ErrInvalidInput = errors.New("invalid input")
)

Functions

func Detail

func Detail(sentinel error, format string, args ...any) error

Detail wraps a sentinel with a printf-style detail message. The returned error.Error() returns just the formatted message (no "<msg>: <sentinel>" suffix), while errors.Is(err, sentinel) is true.

func HTTPStatus

func HTTPStatus(err error) int

HTTPStatus maps a sentinel error to its HTTP status code. Handlers call this with whatever a lower layer returned and let it pick 401/403/404/409/400; anything else is a 500.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL