Skip to main content

Module error

Module error 

Source
Available on crate feature terminal only.
Expand description

Command failure reporting to stdout.

ErrorReport renders a failure, with its source chain and backtrace, as text or JSON. A binary acting as a machine contract also gives the failures a caller is expected to act on a stable code: it declares its own ErrorCode vocabulary, raises a CodedError anywhere in the chain, and evaluates its result with ErrorReport::eval_coded, which prints the code as code beside the message. The message stays for humans and may be reworded at any time; the code is the contract.

A command that ran to its end but did not fully succeed prints its result, then returns a PartialOutcome: the process exits with its status, 2 or above, and prints nothing more.

Structs§

CodedError
A failure carrying an ErrorCode, anywhere in an error chain.
ErrorReport
Wraps an anyhow::Error to render it, with its source chain, backtrace and code, as text or JSON.
PartialOutcome
The outcome of a command that printed its result but did not fully succeed, such as a check with a failed backend or a refusal from a server.

Enums§

NoErrorCode
The empty vocabulary of a binary whose failures carry no code.

Constants§

EXIT_FAILURE
The exit status of a failed command, which printed the failure object.
EXIT_PARTIAL
The exit status of a command that ran to its end and printed its result, whose outcome is not a full success. A command may document higher statuses for other such outcomes.

Traits§

ErrorCode
A binary’s vocabulary of stable failure codes.

Functions§

code_of
The code of the outermost CodedError in the chain, if any.
partial_outcome_of
The PartialOutcome in the chain, if any.