exitcode

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 11 Imported by: 0

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

View Source
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
	// Unavailable: the service cannot be reached or is not serving this
	// 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

func FromError(err error) int

FromError maps any error the CLI can return onto exactly one exit code. nil maps to Success.

func NotImplemented

func NotImplemented(msg string) error

NotImplemented returns the typed error for a stubbed capability.

func UsageError

func UsageError(err error) error

UsageError wraps err as a usage failure. The message is surfaced verbatim.

func VerificationError

func VerificationError(msg string, cause error) error

VerificationError wraps cause as a fail-closed verification failure with a customer-facing message.

Types

This section is empty.

Jump to

Keyboard shortcuts

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