Skip to main content

Module error_class

Module error_class 

Source
Expand description

Deterministic-error classification for the CLI exit contract.

Retry wrappers around anodizer (CI actions, shell loops) need to tell a transient failure (network flake, registry 5xx — worth retrying) from a deterministic one (unparseable config, invalid flag values, the dist-not-empty guard — retrying burns attempts on an identical failure). Two signals carry that classification:

  • exit code EXIT_DETERMINISTIC (2) — the Unix usage-error convention; everything else keeps exit 1.
  • stderr marker CLASS_MARKER — a machine-readable line for wrappers that cannot rely on the exit code (or pin an older anodizer whose deterministic paths still exited 1).

Classification is a conservative allowlist: an error is deterministic only if its construction site wrapped it via deterministic / deterministic_msg. Anything unwrapped — however config-shaped its message looks — stays exit 1, so a transient failure can never be misfiled as unretryable.

Structs§

DeterministicError
Transparent marker wrapper: its presence anywhere in an anyhow chain classifies the whole error as deterministic. Display and source() forward to the wrapped error, so rendered output (top message + caused by: chain) is byte-identical to the unwrapped error.

Constants§

CLASS_MARKER
Machine-readable stderr marker emitted alongside every deterministic error, mirroring the anodizer-output <key>=<value> payload convention.
EXIT_DETERMINISTIC
Exit code for deterministic config/usage errors (Unix usage-error convention, and the code clap already uses for flag-parse errors).

Functions§

deterministic
Mark an error as deterministic. The returned error renders identically; only is_deterministic can tell the difference.
deterministic_msg
deterministic for message-shaped errors — the Result<_, String> validator idiom (.map_err(deterministic_msg)?).
is_deterministic
True when any link of the chain is a DeterministicError marker — context layered on top of a marked error does not hide it.