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§
Sourcefn with_source<Source>(self, source: Source) -> ErrorWithSource<Self, Source>where
Self: Sized,
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
Sourcefn caused<Error>(self, error: Error) -> ErrorWithSource<Error, Self>where
Self: Sized,
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
Sourcefn display_with_sources<I>(&self, infix: I) -> DisplayWithSources<&Self, I>where
Self: Sized,
fn display_with_sources<I>(&self, infix: I) -> DisplayWithSources<&Self, I>where
Self: Sized,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".