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— infallibleu8mapping (zero-cost)ErrorKind::as_str— static&'static strfor JSONerror.kind(zero-cost)- Prefer these helpers over ad-hoc
ascasts when mapping to process status - There is no fallible
TryFrompath: every kind has a fixed exit code
§Cost
| Operation | Cost |
|---|---|
exit_code() | O(1), no allocation |
as_str() | O(1), static slice |
CliError::new / with_suggestion | allocates 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
crate::envelopefor JSON success/error envelopescrate::exit_code_forfor library callers that already hold aCliError
Structs§
- CliError
- Typed CLI error with optional remediation hint.
Enums§
- Error
Kind - High-level failure category mapped to a process exit code.