pub struct Error { /* private fields */ }Expand description
Load-side error.
Carries an inner anyhow::Error for rich diagnostics (chained context,
backtraces) along with a single recoverable bit. Recoverable errors are
the contract for probing APIs: a caller that tries multiple load strategies
(e.g. current version, then legacy) can distinguish “this attempt didn’t
match, try another” from “the data is broken, stop now”.
Most constructors produce critical (non-recoverable) errors. Probing
call sites use the explicit *_recoverable constructors, or rely on the
From<Kind> impl which classifies each Kind variant according to
Kind::is_recoverable.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new_recoverable<E>(err: E) -> Self
pub fn new_recoverable<E>(err: E) -> Self
Construct a recoverable error from an underlying source. Suitable for probing APIs that may attempt an alternative load strategy.
Sourcepub fn message_recoverable<D>(message: D) -> Self
pub fn message_recoverable<D>(message: D) -> Self
Construct a recoverable error from a display message. Suitable for probing APIs that may attempt an alternative load strategy.
Sourcepub fn context<D>(self, message: D) -> Self
pub fn context<D>(self, message: D) -> Self
Attach additional context. The recoverable flag is preserved.
Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Returns true if this error is recoverable. Probing call sites should
only fall back to alternative load strategies when this is true.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if it exists.
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()