[−][src]Struct tracing_error::TracedError
This is supported on
feature="traced-error"
only.A wrapper type for Error
s 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 where 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,
[src]
E: Error,
impl<E> Display for TracedError<E> where
E: Error,
[src]
E: Error,
impl<E> Error for TracedError<E> where
E: Error + 'static,
[src]
E: Error + 'static,
fn source<'a>(&'a self) -> Option<&'a (dyn Error + 'static)>
[src]
fn backtrace(&self) -> Option<&Backtrace>
[src]
fn description(&self) -> &str
1.0.0[src]
fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
impl<E> From<E> for TracedError<E> where
E: Error + Send + Sync + 'static,
[src]
E: Error + Send + Sync + 'static,
Auto Trait Implementations
impl<E> !RefUnwindSafe for TracedError<E>
impl<E> Send for TracedError<E> where
E: Send,
E: Send,
impl<E> Sync for TracedError<E> where
E: Sync,
E: Sync,
impl<E> Unpin for TracedError<E> where
E: Unpin,
E: Unpin,
impl<E> !UnwindSafe for TracedError<E>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,