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, 3 or above, and prints nothing more. A command line the grammar
refuses exits 2, its failure object coded usage-invalid under
--json (see crate::clap::parse).
A command acting on several items lists the failure of each single
item as an ItemError in its result’s errors, then exits 3.
Structs§
- Coded
Error - A failure carrying an
ErrorCode, anywhere in an error chain. - Error
Report - Wraps an
anyhow::Errorto render it, with its source chain, backtrace and code, as text or JSON. - Item
Error - The error of one item a command could not list or act on.
- Item
Errors - The item errors a command prints last, one aligned
Error:line each. - Partial
Outcome - 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§
- Common
Code - The codes pimalaya-cli raises itself, beside every binary’s own vocabulary.
- NoError
Code - 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.
- EXIT_
USAGE - The exit status of a command line the grammar refuses, clap’s own.
Traits§
- Error
Code - A binary’s vocabulary of stable failure codes.
Functions§
- code_of
- The code of the outermost
CodedErrorin the chain, if any. - failure_
status - The status a failure exits with:
EXIT_USAGEwhen its chain is codedCommonCode::UsageInvalid, a command line refused after clap parsed it,EXIT_FAILUREotherwise. - partial_
outcome_ of - The
PartialOutcomein the chain, if any. - usage_
error - The failure of a command line the grammar refuses, coded
CommonCode::UsageInvalid, with clap’s message stripped of itserror:prefix and of its styles. - with_
code erras the report reads it, the codecodefinds in its chain carried by an innermostCodedError.