Skip to main content

ErrorExt

Trait ErrorExt 

Source
pub trait ErrorExt {
    // Required methods
    fn with_source<Source>(
        self,
        source: Source,
    ) -> ErrorWithSource<Self, Source>
       where Self: Sized;
    fn caused<Error>(self, error: Error) -> ErrorWithSource<Error, Self>
       where Self: Sized;
    fn display_with_sources<I>(&self, infix: I) -> DisplayWithSources<&Self, I>
       where Self: Sized;
}
Expand description

An extension trait for Errors

Required Methods§

Source

fn with_source<Source>(self, source: Source) -> ErrorWithSource<Self, Source>
where Self: Sized,

Attach a source to the current error

The value of source will be returned by the Error::source and Error::cause implementations of the returned value. Note that the latter is deprecated.

See also ErrorExt::caused

Source

fn caused<Error>(self, error: Error) -> ErrorWithSource<Error, Self>
where Self: Sized,

Set self as the source of the given error

The value of self will be returned by the Error::source and Error::cause implementations of the returned value. Note that the latter is deprecated.

See also ErrorExt::with_source

Source

fn display_with_sources<I>(&self, infix: I) -> DisplayWithSources<&Self, I>
where Self: Sized,

Display an Error and its sources with a separator

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<This> ErrorExt for This
where This: Error,