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 Error
s.
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