Documentation
¶
Overview ¶
Package apperr defines the typed errors used across the CLI, the MCP server and the internal clients, together with the stable mapping from error to process exit code.
Every failure the user can observe is an *Error with a machine-readable Code and a Category. The Category value is the exit code, so the CLI and the MCP server report failures the same way.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Category ¶
type Category int
Category is the class of a failure. Its numeric value is the process exit code the CLI returns for it.
const ( // Generic is an unclassified failure. Generic Category = 1 // Usage is a bad invocation: unknown flag, invalid value, missing input. Usage Category = 2 // Auth is a missing, expired or rejected session. Auth Category = 3 // NotFound is a missing resource. NotFound Category = 4 // Blocked is a refusal by Repsol, a firewall or a rate limit. Blocked Category = 5 // Network is a transport failure or a timeout on a read. Network Category = 6 // APIChanged means Repsol answered with an unexpected status or shape. APIChanged Category = 7 // Refused means the request was understood but not allowed. Refused Category = 8 // OutcomeUnknown means an order write may or may not have been placed. OutcomeUnknown Category = 9 // Interrupted means the run was cancelled. Interrupted Category = 130 )
The error categories, whose values are the CLI exit codes.
type Error ¶
type Error struct {
// Category is the class of the failure; its value is the exit code.
Category Category
// Code is a snake_case machine code, such as "pending_order".
Code string
// Message is a human-readable, single-line description.
Message string
// Hint tells the user what to do next. It never contains secrets.
Hint string
// HTTPStatus is the status code of the failing response, or 0.
HTTPStatus int
// Endpoint is the API path of the failing call, never a full URL.
Endpoint string
// Retryable reports whether repeating the call could succeed.
Retryable bool
// Err is the wrapped cause, if any.
Err error
}
Error is a failure with a machine-readable code, a category, an optional hint for the user and the HTTP context of the call that failed.
func From ¶
From converts any error into an *Error. It returns nil only for a nil error, and it keeps the fields of an error that already is one.