Struct thiserror_ext::Report
source · 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