pub enum XCheckerError {
Show 18 variants
Config(ConfigError),
Phase(PhaseError),
Claude(ClaudeError),
Runner(RunnerError),
Io(Error),
SecretDetected {
pattern: String,
location: String,
},
PacketOverflow {
used_bytes: usize,
used_lines: usize,
limit_bytes: usize,
limit_lines: usize,
},
ConcurrentExecution {
id: String,
},
PacketPreviewTooLarge {
size: usize,
},
CanonicalizationFailed {
phase: String,
reason: String,
},
ReceiptWriteFailed {
path: String,
reason: String,
},
ModelResolutionError {
alias: String,
resolved: String,
reason: String,
},
Source(SourceError),
Fixup(FixupError),
SpecId(SpecIdError),
Lock(LockError),
Llm(LlmError),
ValidationFailed {
phase: String,
issues: Vec<ValidationError>,
issue_count: usize,
},
}Expand description
Library-level error type with rich context and user-friendly reporting.
XCheckerError is the primary error type returned by xchecker library operations.
It provides:
- Detailed error information for programmatic handling
- User-friendly messages with context and suggestions
- Mapping to CLI exit codes for consistent error reporting
§Error Categories
Errors are organized into categories for better handling:
| Category | Description |
|---|---|
Config | Configuration file or CLI argument errors |
Phase | Phase execution failures |
Claude | Claude CLI integration errors |
Runner | Process execution errors |
SecretDetected | Security: secrets found in content |
PacketOverflow | Resource: packet size exceeded |
Lock | Concurrency: lock already held |
§Exit Code Mapping
Use to_exit_code() to map errors to CLI exit codes:
| Exit Code | Error Type |
|---|---|
| 2 | Configuration/CLI argument errors |
| 7 | Packet overflow |
| 8 | Secret detected |
| 9 | Lock held |
| 10 | Phase timeout |
| 70 | Claude CLI failure |
| 1 | Other errors |
§User-Friendly Messages
Use display_for_user() to get formatted error messages
suitable for end users, including context and actionable suggestions.
§Example
use xchecker_utils::error::XCheckerError;
use xchecker_utils::exit_codes::ExitCode;
fn handle_error(err: XCheckerError) {
// Get user-friendly message
eprintln!("{}", err.display_for_user());
// Map to exit code for CLI
let code = err.to_exit_code();
std::process::exit(code.as_i32());
}§Library vs CLI Usage
- Library consumers: Handle
XCheckerErrordirectly, useto_exit_code()if needed - CLI: Maps errors to exit codes and displays user-friendly messages
Library code returns XCheckerError and does NOT call std::process::exit().
Variants§
Config(ConfigError)
Phase(PhaseError)
Claude(ClaudeError)
Runner(RunnerError)
Io(Error)
SecretDetected
PacketOverflow
ConcurrentExecution
PacketPreviewTooLarge
CanonicalizationFailed
ReceiptWriteFailed
ModelResolutionError
Source(SourceError)
Fixup(FixupError)
SpecId(SpecIdError)
Lock(LockError)
Llm(LlmError)
ValidationFailed
Implementations§
Source§impl XCheckerError
impl XCheckerError
Sourcepub fn display_for_user(&self) -> String
pub fn display_for_user(&self) -> String
Get a user-friendly error message with context and actionable suggestions.
This method combines the error message, context, and suggestions into a single formatted string suitable for display to end users. The format is:
Error: <user message>
Context: <context if available>
Suggestions:
• <suggestion 1>
• <suggestion 2>
...§Example
use xchecker_utils::error::XCheckerError;
let err = XCheckerError::SecretDetected {
pattern: "ghp_".to_string(),
location: "test.txt".to_string(),
};
let message = err.display_for_user();
assert!(message.contains("Security issue"));
assert!(message.contains("Suggestions:"));Sourcepub fn display_for_user_with_redactor(
&self,
redactor: &SecretRedactor,
) -> String
pub fn display_for_user_with_redactor( &self, redactor: &SecretRedactor, ) -> String
Get a user-friendly error message with context and actionable suggestions, applying a caller-provided redactor as a final safety net (FR-SEC-19).
Sourcepub fn to_exit_code(&self) -> ExitCode
pub fn to_exit_code(&self) -> ExitCode
Map this error to the appropriate CLI exit code.
This is the single source of truth for both CLI exit codes and receipt
exit_code fields. The mapping follows the documented exit code table:
| Exit Code | Name | Description |
|---|---|---|
| 0 | SUCCESS | Completed successfully |
| 1 | INTERNAL | General failure |
| 2 | CLI_ARGS | Invalid CLI arguments |
| 7 | PACKET_OVERFLOW | Packet size exceeded |
| 8 | SECRET_DETECTED | Secret found in content |
| 9 | LOCK_HELD | Lock already held |
| 10 | PHASE_TIMEOUT | Phase timed out |
| 70 | CLAUDE_FAILURE | Claude CLI failed |
§Example
use xchecker_utils::error::XCheckerError;
use xchecker_utils::exit_codes::ExitCode;
let err = XCheckerError::SecretDetected {
pattern: "ghp_".to_string(),
location: "test.txt".to_string(),
};
assert_eq!(err.to_exit_code(), ExitCode::SECRET_DETECTED);Trait Implementations§
Source§impl Debug for XCheckerError
impl Debug for XCheckerError
Source§impl Display for XCheckerError
impl Display for XCheckerError
Source§impl Error for XCheckerError
impl Error for XCheckerError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<ClaudeError> for XCheckerError
impl From<ClaudeError> for XCheckerError
Source§fn from(source: ClaudeError) -> XCheckerError
fn from(source: ClaudeError) -> XCheckerError
Source§impl From<ConfigError> for XCheckerError
impl From<ConfigError> for XCheckerError
Source§fn from(source: ConfigError) -> XCheckerError
fn from(source: ConfigError) -> XCheckerError
Source§impl From<Error> for XCheckerError
impl From<Error> for XCheckerError
Source§fn from(source: Error) -> XCheckerError
fn from(source: Error) -> XCheckerError
Source§impl From<FixupError> for XCheckerError
impl From<FixupError> for XCheckerError
Source§fn from(source: FixupError) -> XCheckerError
fn from(source: FixupError) -> XCheckerError
Source§impl From<LlmError> for XCheckerError
impl From<LlmError> for XCheckerError
Source§fn from(source: LlmError) -> XCheckerError
fn from(source: LlmError) -> XCheckerError
Source§impl From<LockError> for XCheckerError
impl From<LockError> for XCheckerError
Source§fn from(source: LockError) -> XCheckerError
fn from(source: LockError) -> XCheckerError
Source§impl From<PhaseError> for XCheckerError
impl From<PhaseError> for XCheckerError
Source§fn from(source: PhaseError) -> XCheckerError
fn from(source: PhaseError) -> XCheckerError
Source§impl From<RunnerError> for XCheckerError
impl From<RunnerError> for XCheckerError
Source§fn from(source: RunnerError) -> XCheckerError
fn from(source: RunnerError) -> XCheckerError
Source§impl From<SourceError> for XCheckerError
impl From<SourceError> for XCheckerError
Source§fn from(source: SourceError) -> XCheckerError
fn from(source: SourceError) -> XCheckerError
Source§impl From<SpecIdError> for XCheckerError
impl From<SpecIdError> for XCheckerError
Source§fn from(source: SpecIdError) -> XCheckerError
fn from(source: SpecIdError) -> XCheckerError
Source§impl UserFriendlyError for XCheckerError
impl UserFriendlyError for XCheckerError
Source§fn user_message(&self) -> String
fn user_message(&self) -> String
Source§fn suggestions(&self) -> Vec<String>
fn suggestions(&self) -> Vec<String>
Source§fn category(&self) -> ErrorCategory
fn category(&self) -> ErrorCategory
Auto Trait Implementations§
impl Freeze for XCheckerError
impl !RefUnwindSafe for XCheckerError
impl Send for XCheckerError
impl Sync for XCheckerError
impl Unpin for XCheckerError
impl UnsafeUnpin for XCheckerError
impl !UnwindSafe for XCheckerError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.