#[non_exhaustive]pub enum MiddlewareError {
Error(Error),
Interrupt(InterruptError),
Cancelled,
}Expand description
Why a stage did not produce a result.
Errors, interrupts and cancellation travel through the chain as values, so a Wrap handler can
see them and decide; ? converts an Error, an Interrupt or an InterruptError into
one.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Error(Error)
The stage failed.
Interrupt(InterruptError)
A handler or the tool raised interrupts.
Cancelled
The invocation was cancelled.
Implementations§
Source§impl MiddlewareError
impl MiddlewareError
Sourcepub fn from_boxed(error: BoxError) -> Self
pub fn from_boxed(error: BoxError) -> Self
Recovers the typed error behind a boxed one, so a handler can ? errors that only
convert into a BoxError: an InterruptError stays an interrupt and a boxed
Error is unwrapped; anything else is Error::Other.
use strands::BoxError;
use strands::middleware::MiddlewareError;
fn lookup() -> Result<u32, BoxError> {
Err("cache unavailable".into())
}
fn handler_step() -> Result<u32, MiddlewareError> {
lookup().map_err(MiddlewareError::from_boxed)
}
assert_eq!(handler_step().unwrap_err().to_string(), "cache unavailable");Trait Implementations§
Source§impl Debug for MiddlewareError
impl Debug for MiddlewareError
Source§impl Display for MiddlewareError
impl Display for MiddlewareError
Source§impl Error for MiddlewareError
impl Error for MiddlewareError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<Error> for MiddlewareError
impl From<Error> for MiddlewareError
Source§impl From<Interrupt> for MiddlewareError
impl From<Interrupt> for MiddlewareError
Source§impl From<InterruptError> for MiddlewareError
impl From<InterruptError> for MiddlewareError
Source§fn from(interrupts: InterruptError) -> Self
fn from(interrupts: InterruptError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for MiddlewareError
impl !UnwindSafe for MiddlewareError
impl Freeze for MiddlewareError
impl Send for MiddlewareError
impl Sync for MiddlewareError
impl Unpin for MiddlewareError
impl UnsafeUnpin for MiddlewareError
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
Converts
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> ⓘ
Converts
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 moreCreates a shared type from an unshared type.