Trait ErrorTracer

Source
pub trait ErrorTracer<E>: ErrorMessageTracer {
    // Required methods
    fn new_trace(err: E) -> Self;
    fn add_trace(self, err: E) -> Self;
}
Expand description

An error tracer implements ErrorTracer<E> if it supports more sophisticated error tracing for an error type E. The contraint for E depends on the specific error tracer implementation.

For example, EyreTracer and AnyhowTracer requires an error type to satisfy E: Error + Send + Sync + 'static.

The error tracer also requires ownership of the source error to be transferred to the error tracer. Because of this, it may not be possible to extract a source error type to be used as both error detail and error trace. We also should not expect E to implement Clone, as error types such as eyre::Report do not implement Clone.

Required Methods§

Source

fn new_trace(err: E) -> Self

Create a new error trace from E, also taking ownership of it.

This calls the underlying methods such as eyre::Report::new and anyhow::Error::new.

Source

fn add_trace(self, err: E) -> Self

Add a new error trace from E. In the current underlying implementation, this is effectively still has the same behavior as ErrorMessageTracer::add_message. This is because eyre and anyhow do not support adding new set of backtraces to an existing trace. So effectively, currently the error tracers can track at most one backtrace coming from the original error source.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<E> ErrorTracer<E> for AnyhowTracer
where E: Display + Debug + Send + Sync + 'static,

Source§

impl<E> ErrorTracer<E> for EyreTracer
where E: Display + Debug + Send + Sync + 'static,

Source§

impl<E: Display> ErrorTracer<E> for StringTracer