Documentation
¶
Overview ¶
Package exitcode is the CLI's single exit-code authority.
The table below is the design doc's §16.5 contract plus the CRID verification code (12) and the conventional SIGINT code (130). Every error the CLI can surface maps to exactly one code, and it maps in exactly one place: FromError. Commands never call os.Exit and never pick numbers; they return errors, and main exits with FromError's answer.
The mapping is guarded two ways in exitcode_test.go: a table-driven test pins every defined sentinel to its code, and a source scan fails the build when a new Err* sentinel appears anywhere under apps/cli without a row in that table.
Index ¶
Constants ¶
const ( // Success: the command did what was asked. Success = 0 // General: an unclassified failure, including features not yet available // in this build. General = 1 // Usage: the command line itself was wrong (flags, arguments, missing // confirmation). Usage = 2 // Config: configuration files or profiles are invalid. Config = 3 // Auth: no credential, an implausible credential, or the service // rejected the credential (HTTP 401). Auth = 4 // NotFound: the resource does not exist or is retired (HTTP 404/410). NotFound = 5 // Forbidden: the credential lacks permission (HTTP 403). Forbidden = 6 // Conflict: the request conflicts with current state (HTTP 409). Conflict = 7 // InvalidInput: an operand or request the service (or the local gate, // for inputs that can never be valid) rejected as invalid. InvalidInput = 8 // RateLimited: still rate limited after the transport's bounded retries // (HTTP 429). RateLimited = 9 // ServerError: the service failed (HTTP 5xx other than 503) or answered // outside its contract. ServerError = 10 // surface (HTTP 503, network failures, timeouts). Unavailable = 11 // VerificationFailed: the response failed CRID-anchored verification. // Nothing was emitted; treat as tampering, not transience. VerificationFailed = 12 // Interrupted: the run was canceled (SIGINT convention 128+2). Interrupted = 130 )
The exit-code table (§16.5 plus 12 and 130).
Variables ¶
This section is empty.
Functions ¶
func FromError ¶
FromError maps any error the CLI can return onto exactly one exit code. nil maps to Success.
func NotImplemented ¶
NotImplemented returns the typed error for a stubbed capability.
func UsageError ¶
UsageError wraps err as a usage failure. The message is surfaced verbatim.
func VerificationError ¶
VerificationError wraps cause as a fail-closed verification failure with a customer-facing message.
Types ¶
This section is empty.