Documentation
¶
Overview ¶
Package fault is the shared error taxonomy for the funcd platform (ADR-0002). It is stdlib-only and imported "up" by internal/** and pkg/**; it imports nothing beyond the standard library. Every layer builds errors from this package; the API edge maps them to RFC 9457 application/problem+json.
Index ¶
- func WriteProblem(w http.ResponseWriter, err error)
- type Error
- func Conflictf(op, format string, a ...any) *Error
- func Forbiddenf(op, format string, a ...any) *Error
- func Internalf(op, format string, a ...any) *Error
- func Invalidf(op, format string, a ...any) *Error
- func NotFoundf(op, format string, a ...any) *Error
- func PayloadTooLargef(op, format string, a ...any) *Error
- func ResourceExhaustedf(op, format string, a ...any) *Error
- func Unauthorizedf(op, format string, a ...any) *Error
- func Unavailablef(op, format string, a ...any) *Error
- func Wrapf(err error, k Kind, op, format string, a ...any) *Error
- type Kind
- type Problem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteProblem ¶
func WriteProblem(w http.ResponseWriter, err error)
WriteProblem writes an error as an RFC 9457 application/problem+json response. It sets Content-Type and writes the JSON body.
Types ¶
type Error ¶
type Error struct {
Kind Kind
Op string // e.g. "store.Get", "blob.Put" — free string, open set
Msg string // human-readable, safe to surface to callers
Detail map[string]string // deliberately flat, key-value diagnostic pairs
Err error // wrapped cause
}
Error is the typed error used throughout the platform. It carries a Kind (for HTTP mapping), an Op (free string describing the operation that failed), a human-readable Msg, optional flat Detail (key-value pairs), and the wrapped cause via Err.
func Forbiddenf ¶
Forbiddenf builds a Forbidden error with a formatted message.
func PayloadTooLargef ¶
PayloadTooLargef builds a PayloadTooLarge error (413) with a formatted message.
func ResourceExhaustedf ¶
ResourceExhaustedf builds a ResourceExhausted error (429) with a formatted message.
func Unauthorizedf ¶
Unauthorizedf builds an Unauthorized error with a formatted message.
func Unavailablef ¶
Unavailablef builds an Unavailable error with a formatted message.
type Kind ¶
type Kind string
Kind is the machine-readable error kind — the stable identifier that maps to HTTP status codes and problem+json type URIs. Kinds are an open set but the enumerated constants below cover every case the platform needs.
const ( // Invalid means the request is malformed or a required dependency is missing. Invalid Kind = "invalid" // NotFound means the requested resource does not exist. NotFound Kind = "not_found" // Conflict means the request conflicts with the current state (e.g. duplicate name). Conflict Kind = "conflict" Unauthorized Kind = "unauthorized" // Forbidden means the authenticated identity lacks permission. Forbidden Kind = "forbidden" Unavailable Kind = "unavailable" // ResourceExhausted means a rate/quota limit was exceeded (429 Too Many Requests). ResourceExhausted Kind = "resource_exhausted" // PayloadTooLarge means a payload, key, object or record is over a size cap funcd enforces (413 // Content Too Large when it answers HTTP). PayloadTooLarge Kind = "payload_too_large" // Internal means an unexpected internal error occurred. Internal Kind = "internal" )