Skip to main content

classify_anyhow_error

Function classify_anyhow_error 

Source
pub fn classify_anyhow_error(err: &Error) -> ErrorCategory
Expand description

Classify an anyhow::Error into a canonical ErrorCategory.

This uses string matching as a last resort when the original error type has been erased through anyhow wrapping. Typed conversions (e.g., From<LLMError>) should be preferred where the original error type is available.

Recovery decisions are made by type when it survives the anyhow boundary. The outermost context layer is classified first (preserving the intentional wording of a deliberate .context(...)), but when that layer is uninformative we consult the typed root and then the remaining cause chain. Without this, a wrapping .context("...") message alone would hide the underlying category — e.g. an LLMError::RateLimit buried under "compaction failed" would fall through to ExecutionError and lose its retry/recovery policy.