[][src]Struct tracing_error::TracedError

pub struct TracedError<E> { /* fields omitted */ }
This is supported on feature="traced-error" only.

A wrapper type for Errors that bundles a SpanTrace with an inner Error type.

This type is a good match for the error-kind pattern where you have an error type with an inner enum of error variants and you would like to capture a span trace that can be extracted during printing without formatting the span trace as part of your display impl.

An example of implementing an error type for a library using TracedError might look like this

This example deliberately fails to compile
#[derive(Debug, thiserror::Error)]
pub struct Error {
    source: TracedError<Kind>,
    backtrace: Backtrace,

impl fmt::Display for Error {
    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
        fmt::Display::fmt(&self.source, fmt)

impl<E> From<E> for Error
    Kind: From<E>,
    fn from(source: E) -> Self {
        Self {
            source: Kind::from(source).into(),
            backtrace: Backtrace::capture(),

Trait Implementations

impl<E> Debug for TracedError<E> where
    E: Error

impl<E> Display for TracedError<E> where
    E: Error

impl<E> Error for TracedError<E> where
    E: Error + 'static, 

impl<E> From<E> for TracedError<E> where
    E: Error + Send + Sync + 'static, 

Auto Trait Implementations

impl<E> !RefUnwindSafe for TracedError<E>

impl<E> Send for TracedError<E> where
    E: Send

impl<E> Sync for TracedError<E> where
    E: Sync

impl<E> Unpin for TracedError<E> where
    E: Unpin

impl<E> !UnwindSafe for TracedError<E>

Blanket Implementations

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

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

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> From<!> for T[src]

impl<T> From<T> for T[src]

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

impl<T> ToString for T where
    T: Display + ?Sized

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

type Error = Infallible

The type returned in the event of a conversion error.

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.