exitcode

package
v0.19.5 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 2 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func Resolve(err error) int

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

func Wrap(code int, err error) error

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

func WrapSummary(code int, err error, summary string) error

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.

Types

type ExitError

type ExitError struct {
	Code    int
	Message string
	Err     error
}

ExitError carries a process exit code alongside an error or message. Construct it directly with a Code and Message, or via Wrap to annotate an existing error.

func (*ExitError) Error

func (e *ExitError) Error() string

func (*ExitError) Unwrap

func (e *ExitError) Unwrap() error

Jump to

Keyboard shortcuts

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