Skip to main content

Module error

Module error 

Source
Expand description

Typed CLI errors and exit codes. Typed CLI errors with sysexits-style exit codes.

§Error kinds

ErrorKind maps to process exit codes used by the binary and JSON envelopes. Stable machine strings come from ErrorKind::as_str.

§Conversions

  • CliError::exit_code / ErrorKind::exit_code — infallible u8 mapping (zero-cost)
  • ErrorKind::as_str — static &'static str for JSON error.kind (zero-cost)
  • Prefer these helpers over ad-hoc as casts when mapping to process status
  • There is no fallible TryFrom path: every kind has a fixed exit code

§Cost

OperationCost
exit_code()O(1), no allocation
as_str()O(1), static slice
CliError::new / with_suggestionallocates String message (and optional suggestion)

§Examples

use browser_automation_cli::error::{CliError, ErrorKind};

let err = CliError::with_suggestion(
    ErrorKind::Unavailable,
    "chrome not found",
    "install Chromium or Google Chrome",
);
assert_eq!(err.exit_code(), 69);
assert_eq!(err.kind().as_str(), "unavailable");

§See also

Structs§

CliError
Typed CLI error with optional remediation hint.

Enums§

ErrorKind
High-level failure category mapped to a process exit code.