pub struct Error { /* private fields */ }Expand description
A failure, classified once at the point it is raised.
Carries the coarse ErrorKind every consumer branches on, the optional
WireKind naming the daemon status that produced it, a message that names
the docs/PLATFORM.md finding when a trap closure raised it, and the
underlying error when one exists.
Deliberately a struct with a private body rather than an enum: the variants a caller wants to match on are the kinds, and an enum over every raise site would make every new failure a breaking change for a binding that matched exhaustively.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(kind: ErrorKind, message: impl Into<String>) -> Self
pub fn new(kind: ErrorKind, message: impl Into<String>) -> Self
A failure of kind, with a message that should name its finding.
Sourcepub fn invalid_arg(message: impl Into<String>) -> Self
pub fn invalid_arg(message: impl Into<String>) -> Self
A local reject: the request was refused before any AWS call.
The shorthand exists because every trap closure in this crate ends in one,
and ERR_INVALID_ARG is the code that tells a caller the fix is theirs and
costs nothing.
Sourcepub fn with_source(self, source: impl Error + Send + Sync + 'static) -> Self
pub fn with_source(self, source: impl Error + Send + Sync + 'static) -> Self
Attaches the underlying error, reachable through std::error::Error::source.
Sourcepub fn with_throttled(self, throttled: bool) -> Self
pub fn with_throttled(self, throttled: bool) -> Self
Marks a control-plane throttle without parsing its explanation.
Sourcepub fn with_retry_details(self, attempts: u32, backoff: Duration) -> Self
pub fn with_retry_details(self, attempts: u32, backoff: Duration) -> Self
Attaches the attempts and completed retry sleeps for this control-plane call.
Sourcepub fn attempt_count(&self) -> u32
pub fn attempt_count(&self) -> u32
Attempts sent for the failed call, or zero when no request telemetry is available.
Sourcepub fn wire_kind(&self) -> Option<WireKind>
pub fn wire_kind(&self) -> Option<WireKind>
The daemon status this came from, when it came from one.
None for every local reject and every control-plane failure — those never
reached the in-VM daemon, so there is no status to report.
Sourcepub fn code(&self) -> &'static str
pub fn code(&self) -> &'static str
The machine-readable ERR_* code, as cli.py’s Code spells it.
Sourcepub fn retryable(&self) -> bool
pub fn retryable(&self) -> bool
Whether retrying the identical request could plausibly succeed.
Derived from the kind rather than stored, so it cannot drift from it: the
five retryable daemon conditions all map to ErrorKind::Retryable, which
is what makes this one comparison instead of a second table.
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)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()