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

Note: in most cases you can use Error::from or a call from StackableErr instead of these functions.

source

pub fn empty() -> Self

Returns an empty error stack

source

pub fn new() -> Self

Returns an error stack with just a UnitError and location information

source

pub fn from_err<E: Error + Send + Sync + 'static>(e: E) -> Self

Returns an error stack with a BoxedError around e, and location info.

source

pub fn from_err_locationless<E: Error + Send + Sync + 'static>(e: E) -> Self

Same as Error::from_err but without location.

source

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

Returns an error stack with just kind.

source

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

Same as Error::from_kind but without location.

source

pub fn from_box(e: Box<dyn Error + Send + Sync>) -> Self

Returns an error stack with just a BoxedErr.

source

pub fn from_box_locationless(e: Box<dyn Error + Send + Sync>) -> Self

Same as Error::from_box but without location.

source

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.

source

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

Same as Error::add_kind but without location.

source

pub fn add_location(self) -> Self

Only adds track_caller location to the stack

source

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

Moves the stack of other onto self

source

pub fn timeout() -> Self

Returns a base TimeoutError error

source

pub fn probably_not_root_cause() -> Self

Returns a base ProbablyNotRootCauseError error

source

pub fn is_timeout(&self) -> bool

Returns if a TimeoutError is in the error stack

source

pub fn is_probably_not_root_cause(&self) -> bool

Returns if a ProbablyNotRootCauseError is in the error stack

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 Default for Error

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display 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 + Send + Sync>> for Error

source§

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

Converts to this type from the input type.
source§

impl From<Cow<'static, str>> for Error

source§

fn from(e: Cow<'static, str>) -> 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<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 StackableErr for Error

§

type Output = Result<(), Error>

source§

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

Pushes the result of f and location information to the stack
source§

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

Pushes the result of f without location information
source§

fn stack(self) -> Self::Output

Pushes just location information to the stack
source§

fn stack_locationless(self) -> Self::Output

Only converts to 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 T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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, U> Into<U> for T
where 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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.