Trait ErrorSource

Source
pub trait ErrorSource<Trace> {
    type Source;
    type Detail;

    // Required method
    fn error_details(source: Self::Source) -> (Self::Detail, Option<Trace>);
}
Expand description

A type implementing ErrorSource<Trace> is a proxy type that provides the capability of extracting from an error source of type Self::Source, returning error detail of type Self::Detail, and an optional error tracer of type Tracer.

The proxy type Self is not used anywhere. We separate out Self and Self::Source so that there can be different generic implementations of error sources, such as for all E: Display or for all E: Error.

There are currently 4 types of error sources:

  • NoSource - Indicating the lack of any error source
  • DisplayError - An error source that implements Display to be used for tracing, and also be stored as detail.
  • DisplayOnly - An error source that implements Display to be used for tracing, and discarded instead of being stored as detail.
  • DetailOnly - An error source that is used as detail and do not contain any error trace.
  • TraceError - An error source that implements Error and used only for tracing.
  • TraceClone - An error source that implements Error and have a cloned copy as detail.

Required Associated Types§

Source

type Source

The type of the error source.

Source

type Detail

The type of the error detail that can be extracted from the error source

Required Methods§

Source

fn error_details(source: Self::Source) -> (Self::Detail, Option<Trace>)

Extracts the error details out from the error source, together with an optional error trace.

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<Detail, Trace> ErrorSource<Trace> for DetailOnly<Detail>

Source§

type Detail = Detail

Source§

type Source = Detail

Source§

impl<E, Tracer> ErrorSource<Tracer> for DisplayError<E>
where E: Display, Tracer: ErrorMessageTracer,

Source§

impl<E, Tracer> ErrorSource<Tracer> for DisplayOnly<E>
where E: Display, Tracer: ErrorMessageTracer,

Source§

impl<E, Tracer> ErrorSource<Tracer> for TraceClone<E>
where E: Clone, Tracer: ErrorTracer<E>,

Source§

impl<E, Tracer> ErrorSource<Tracer> for TraceError<E>
where Tracer: ErrorTracer<E>,

Source§

impl<Trace> ErrorSource<Trace> for NoSource

Source§

impl<Trace> ErrorSource<Trace> for TraceOnly<Trace>

Source§

type Detail = ()

Source§

type Source = Trace