Documentation
¶
Overview ¶
Package exitcode maps errors to process exit codes. Lower layers return plain or sentinel errors; the cmd boundary annotates them with a code via Wrap (or returns an ExitError directly), and main resolves the final code via Resolve. This package is a leaf; it defines the generic exit-code vocabulary (ADR-0003) and leaves domain-specific codes to the consuming apps.
Index ¶
Constants ¶
const ( OK = 0 // success Usage = 1 // bad flags/args; default for unclassified errors Config = 2 // invalid config / validation failure Runtime = 3 // external command, network, or IO failure Interrupted = 130 // canceled via SIGINT/SIGTERM (128+SIGINT) Internal = 70 // unexpected internal condition (sysexits EX_SOFTWARE) )
Generic exit-code vocabulary shared across the adaouat CLI family (ADR-0003). Apps define their own domain codes in the reserved range 4-69.
Variables ¶
This section is empty.
Functions ¶
func Resolve ¶
Resolve maps an error to an exit code: nil → 0, an error carrying an exit code → that code, a context.Canceled error (e.g. a Ctrl-C'd run) → 130, anything else → 1 (the generic failure default).
func Wrap ¶
Wrap annotates err with an exit code. It returns nil when err is nil. If err already carries an exit code (anywhere in its chain), the original code is preserved — the first/innermost classification wins.
func WrapSummary ¶ added in v0.18.0
WrapSummary annotates err with an exit code and a short display summary, while keeping err reachable via Unwrap for errors.Is/errors.As classification. Error() prefers the summary once set, so it displays instead of the full err — use it at a boundary where the full error was already shown elsewhere (e.g. a ui.Spinner step) and the top-level error display (e.g. fang's error panel) shouldn't repeat it, right before returning from a command's RunE:
if err := pipeline.Run(ctx); err != nil {
return exitcode.WrapSummary(exitcode.Runtime, err, "release failed")
}
Like Wrap, if err already carries an exit code anywhere in its chain, that code is preserved — the first/innermost classification wins — but the summary still attaches on top of it.