Documentation
¶
Overview ¶
Package fault classifies errors by what the caller can do about them, so every transport answers the same failure the same way. An owner marks its own errors with a Kind; HTTP maps a Kind to a status and MCP to a readable refusal, each in one place, instead of every handler re-deriving the table.
The Kind describes the failure, not the transport: NotFound, not 404.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Message ¶
Message is what the caller should read. A sentinel made with New only names a category, and the text wrapped around it carries the specifics, so the whole chain reads. An owner's own error type (a denial, a refused retry) is complete in itself, so only its words read, without the context layers added on the way out.
Types ¶
type Classified ¶
Classified is implemented by an error that knows its Kind. Owners with their own error types (a denial with a code, a conflict with detail) implement it rather than wrapping.
type Coded ¶
Coded is implemented by an error that carries a stable machine code, such as a denial's reason code, for clients that branch on it.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is an error with a Kind. It wraps an underlying error when there is one.
type Kind ¶
type Kind uint8
Kind is what went wrong, from the caller's side.
const ( // Internal is an unclassified failure: the caller cannot fix it. Internal Kind = iota // Invalid input: the caller can correct the request. Invalid // Unauthenticated: no verified caller. Unauthenticated // Forbidden: the caller is known and may not do this. Forbidden // NotFound: the thing addressed does not exist (or is not visible). NotFound // Conflict: the request clashes with the current state; retrying after // reading it again may succeed. Conflict // Unprocessable: well-formed, but the current state cannot accept it. Unprocessable Unavailable )