Struct stacked_errors::Error
source · pub struct Error {
pub stack: ThinVec<(ErrorKind, Option<&'static Location<'static>>)>,
}Expand description
An error struct that has an internal stack for different kinds of errors and
Locations. This is a replacement for the bad
information you get from backtraces within async tasks.
Fields§
§stack: ThinVec<(ErrorKind, Option<&'static Location<'static>>)>Implementations§
source§impl Error
impl Error
Note: in most cases you can use Error::from or a call from StackableErr
instead of these functions.
sourcepub fn from_err<E: Error + Send + Sync + 'static>(e: E) -> Self
pub fn from_err<E: Error + Send + Sync + 'static>(e: E) -> Self
Returns an error stack with a BoxedError around e, and location
info.
sourcepub fn from_err_locationless<E: Error + Send + Sync + 'static>(e: E) -> Self
pub fn from_err_locationless<E: Error + Send + Sync + 'static>(e: E) -> Self
Same as Error::from_err but without location.
sourcepub fn from_kind_locationless<K: Into<ErrorKind>>(kind: K) -> Self
pub fn from_kind_locationless<K: Into<ErrorKind>>(kind: K) -> Self
Same as Error::from_kind but without location.
sourcepub fn from_box(e: Box<dyn Error + Send + Sync>) -> Self
pub fn from_box(e: Box<dyn Error + Send + Sync>) -> Self
Returns an error stack with just a BoxedErr.
sourcepub fn from_box_locationless(e: Box<dyn Error + Send + Sync>) -> Self
pub fn from_box_locationless(e: Box<dyn Error + Send + Sync>) -> Self
Same as Error::from_box but without location.
sourcepub fn add_kind<K: Into<ErrorKind>>(self, kind: K) -> Self
pub fn add_kind<K: Into<ErrorKind>>(self, kind: K) -> Self
Adds kind to the error stack alongside location information. Use
StackableErr instead of this if anything expensive in creating the
error is involved, because stack_err uses a closure analogous to
ok_or_else.
sourcepub fn add_kind_locationless<K: Into<ErrorKind>>(self, kind: K) -> Self
pub fn add_kind_locationless<K: Into<ErrorKind>>(self, kind: K) -> Self
Same as Error::add_kind but without location.
sourcepub fn add_location(self) -> Self
pub fn add_location(self) -> Self
Only adds track_caller location to the stack
sourcepub fn chain_errors(self, other: Self) -> Self
pub fn chain_errors(self, other: Self) -> Self
Moves the stack of other onto self
sourcepub fn probably_not_root_cause() -> Self
pub fn probably_not_root_cause() -> Self
Returns a base ProbablyNotRootCauseError error
sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
Returns if a TimeoutError is in the error stack
sourcepub fn is_probably_not_root_cause(&self) -> bool
pub fn is_probably_not_root_cause(&self) -> bool
Returns if a ProbablyNotRootCauseError is in the error stack
Trait Implementations§
source§impl From<FromUtf16Error> for Error
impl From<FromUtf16Error> for Error
source§fn from(e: FromUtf16Error) -> Self
fn from(e: FromUtf16Error) -> Self
source§impl From<FromUtf8Error> for Error
impl From<FromUtf8Error> for Error
source§fn from(e: FromUtf8Error) -> Self
fn from(e: FromUtf8Error) -> Self
source§impl From<ParseFloatError> for Error
impl From<ParseFloatError> for Error
source§fn from(e: ParseFloatError) -> Self
fn from(e: ParseFloatError) -> Self
source§impl From<ParseIntError> for Error
impl From<ParseIntError> for Error
source§fn from(e: ParseIntError) -> Self
fn from(e: ParseIntError) -> Self
source§impl From<TryFromIntError> for Error
impl From<TryFromIntError> for Error
source§fn from(e: TryFromIntError) -> Self
fn from(e: TryFromIntError) -> Self
source§impl StackableErr for Error
impl StackableErr for Error
type Output = Result<(), Error>
source§fn stack_err<K: Into<ErrorKind>, F: FnOnce() -> K>(self, f: F) -> Self::Output
fn stack_err<K: Into<ErrorKind>, F: FnOnce() -> K>(self, f: F) -> Self::Output
f and location information to the stacksource§fn stack_err_locationless<K: Into<ErrorKind>, F: FnOnce() -> K>(
self,
f: F
) -> Self::Output
fn stack_err_locationless<K: Into<ErrorKind>, F: FnOnce() -> K>( self, f: F ) -> Self::Output
f without location informationsource§fn stack_locationless(self) -> Self::Output
fn stack_locationless(self) -> Self::Output
Self::Output