Skip to main content

classify_io_error

Function classify_io_error 

Source
pub fn classify_io_error(error: &Error) -> (u16, SuggestedFix, CodeAction)
Expand description

Classifies a std::io::Error for RFC 9457 rendering.

Every crate wrapping a bare I/O failure (reading an input file, an ontology definition, a cached model file, …) uses this to agree on how a likely path mistake differs from a genuine I/O fault.

std::io::ErrorKind::NotFound and std::io::ErrorKind::PermissionDenied are treated as probably-caller-input mistakes — a 4xx status (404/403 respectively) with Applicability::MaybeIncorrect and a “verify the path” suggested fix. Every other kind is treated as a genuine I/O fault — status 500 with Applicability::Unspecified and a fix that does not imply user error, since an agent branching on the numeric status field must not misclassify a disk/permissions failure as something the caller can simply correct and retry.

§Returns

The (status, suggested_fix, code_action) triple to attach to the envelope in place of the caller’s own static defaults.