Trait flex_error::ErrorTracer [−][src]
pub trait ErrorTracer<E>: ErrorMessageTracer { 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
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
.
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.