Struct Report
pub struct Report<'a>(pub &'a dyn Error);
Expand description
A wrapper around an error that provides a cleaned up error trace for display and debug formatting.
Constructed using AsReport::as_report
.
§Formatting
The report can be formatted using fmt::Display
or fmt::Debug
,
which differs based on the alternate flag (#
).
-
Without the alternate flag, the error is formatted in a compact way:
Outer error text: Middle error text: Inner error text
-
With the alternate flag, the error is formatted in a multi-line format, which is more readable:
Outer error text Caused by these errors (recent errors listed first): 1. Middle error text 2. Inner error text
-
Additionally,
fmt::Debug
provide backtraces if available.
§Error source cleaning
It’s common for errors with a source
to have a Display
implementation that includes their source text as well:
Outer error text: Middle error text: Inner error text
This works for smaller errors without much detail, but can be annoying when trying to format the error in a more structured way, such as line-by-line:
1. Outer error text: Middle error text: Inner error text
2. Middle error text: Inner error text
3. Inner error text
This iterator compares each pair of errors in the source chain, removing the source error’s text from the containing error’s text:
1. Outer error text
2. Middle error text
3. Inner error text
Tuple Fields§
§0: &'a dyn Error
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Report<'a>
impl<'a> !RefUnwindSafe for Report<'a>
impl<'a> !Send for Report<'a>
impl<'a> !Sync for Report<'a>
impl<'a> Unpin for Report<'a>
impl<'a> !UnwindSafe for Report<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request