Struct stacked_errors::Error

source ·
pub struct Error(pub ErrorInner);
Expand description

An experimental error struct that has an internal stack for different kinds of errors and a stack for locations. This is a replacement for the bad information you get from backtraces within async tasks.

Note

Import the MapAddError trait and use .map_add_err instead of map_err or other such functions.

Use at least .map_add_err(|| ()) before every time an error is propogated up the stack to make sure the location stack is filled.

Tuple Fields§

§0: ErrorInner

Implementations§

source§

impl Error

source

pub fn from_kind<K: Into<ErrorKind>>(kind: K) -> Self

Use MapAddErr instead of this

source

pub fn timeout() -> Self

Returns a base timeout error

source

pub fn boxed(e: Box<dyn Error>) -> Self

Can handle anything implementing std::error::Error. Most often called like Err(Error::boxed(Box::new(e))) or .map_err(|e| Error::boxed(Box::new(e) as Box<dyn std::error::Error>)).map_add_err(|| "more info and a location")?.

source

pub fn add_err_no_location<K: Into<ErrorKind>>(self, kind: K) -> Self

The same as Error::add_err but without pushing location to stack

source

pub fn add_err<K: Into<ErrorKind>>(self, kind: K) -> Self

Use MapAddErr instead of this if anything expensive in creating the error is involved, because map_add_err uses a closure analogous to ok_or_else.

source

pub fn add_location(self) -> Self

Only adds track_caller location to the stack

source

pub fn is_timeout(&self) -> bool

Returns if a TimeoutError is in the error stack

source

pub fn chain_errors(self, other: Self) -> Self

Chains the stacks of other onto self

Trait Implementations§

source§

impl Debug for Error

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&'static str> for Error

source§

fn from(e: &'static str) -> Self

Converts to this type from the input type.
source§

impl From<()> for Error

source§

fn from(e: ()) -> Self

Converts to this type from the input type.
source§

impl From<Box<dyn Error + 'static, Global>> for Error

source§

fn from(e: Box<dyn Error>) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(e: Error) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(e: Error) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(e: Error) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(e: Error) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(e: Error) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(e: Error) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(e: Error) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(e: Error) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(e: Error) -> Self

Converts to this type from the input type.
source§

impl From<FromUtf16Error> for Error

source§

fn from(e: FromUtf16Error) -> Self

Converts to this type from the input type.
source§

impl From<FromUtf8Error> for Error

source§

fn from(e: FromUtf8Error) -> Self

Converts to this type from the input type.
source§

impl From<JoinError> for Error

source§

fn from(e: JoinError) -> Self

Converts to this type from the input type.
source§

impl From<ParseFloatError> for Error

source§

fn from(e: ParseFloatError) -> Self

Converts to this type from the input type.
source§

impl From<ParseIntError> for Error

source§

fn from(e: ParseIntError) -> Self

Converts to this type from the input type.
source§

impl From<String> for Error

source§

fn from(e: String) -> Self

Converts to this type from the input type.
source§

impl From<TryFromIntError> for Error

source§

fn from(e: TryFromIntError) -> Self

Converts to this type from the input type.
source§

impl MapAddError for Error

§

type Output = Result<(), Error>

source§

fn map_add_err<K: Into<ErrorKind>, F: FnOnce() -> K>(self, f: F) -> Self::Output

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !Send for Error

§

impl !Sync for Error

§

impl Unpin for Error

§

impl !UnwindSafe for Error

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more