#[non_exhaustive]pub struct StepError { /* private fields */ }Expand description
Error from a step operation.
Use kind() to determine the failure mode and
source() to reach the escaping error.
§Examples
use aws_durable_execution_sdk::{StepError, StepErrorKind};
fn describe(err: &StepError) -> String {
match err.kind() {
// The body's error, also when the retry strategy stopped. Its
// `source()` is that error, and `{:#}` flattens the chain.
StepErrorKind::ExecutionFailed { .. } => format!("body failed: {err:#}"),
_ => format!("{err:#}"),
}
}Implementations§
Source§impl StepError
impl StepError
Sourcepub fn kind(&self) -> &StepErrorKind
pub fn kind(&self) -> &StepErrorKind
Returns the specific kind of step error.
Sourcepub fn execution_failed(source: impl Into<BoxError>) -> Self
pub fn execution_failed(source: impl Into<BoxError>) -> Self
Creates the error a retry strategy receives for a step body, a
wait_for_callback submitter or a with_retry attempt that
returned source.
Its kind is StepErrorKind::ExecutionFailed, and its
source() is source. A test uses it
to call a retry strategy with the error the SDK passes.
§Examples
use std::time::Duration;
use aws_durable_execution_sdk::{RetryDecision, StepError, StepErrorKind};
/// Retries a body error twice, one second apart, and never retries an
/// interrupted attempt.
fn strategy(err: &StepError, attempt: u32) -> RetryDecision {
if matches!(err.kind(), StepErrorKind::Interrupted { .. }) || attempt >= 3 {
RetryDecision::Stop
} else {
RetryDecision::retry(Duration::from_secs(1))
}
}
assert_eq!(
strategy(&StepError::execution_failed("throttled"), 1),
RetryDecision::retry(Duration::from_secs(1))
);
assert_eq!(strategy(&StepError::execution_failed("throttled"), 3), RetryDecision::Stop);
assert_eq!(strategy(&StepError::interrupted(), 1), RetryDecision::Stop);Sourcepub fn interrupted() -> Self
pub fn interrupted() -> Self
Creates the error a retry strategy receives for an interrupted
AtMostOncePerRetry attempt.
Its kind is StepErrorKind::Interrupted, and its
source() displays the message the SDK
records for an interrupted attempt: The step execution process was initiated but failed to reach completion due to an interruption.
Trait Implementations§
Source§impl Error for StepError
impl Error for StepError
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()
Auto Trait Implementations§
impl !RefUnwindSafe for StepError
impl !UnwindSafe for StepError
impl Forget for StepError
impl Freeze for StepError
impl Move for StepError
impl Send for StepError
impl Sync for StepError
impl Unpin for StepError
impl UnsafeUnpin for StepError
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more