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
impl Error
sourcepub fn boxed(e: Box<dyn Error>) -> Self
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")?
.
sourcepub fn add_err_no_location<K: Into<ErrorKind>>(self, kind: K) -> Self
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
sourcepub fn add_err<K: Into<ErrorKind>>(self, kind: K) -> Self
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
.
sourcepub fn add_location(self) -> Self
pub fn add_location(self) -> Self
Only adds track_caller
location to the stack
sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
Returns if a TimeoutError
is in the error stack
sourcepub fn chain_errors(self, other: Self) -> Self
pub fn chain_errors(self, other: Self) -> Self
Chains the stacks of other
onto self