Derive Macro ReportDebug
#[derive(ReportDebug)]
Expand description
Generates the [Debug
] implementation that delegates to the Report
of
an error.
Generally, the [Debug
] representation of an error should not be used in
user-facing scenarios. However, if [Result::unwrap
] or [Result::expect
]
is called, or an error is used as Termination
, the standard library
will format the error with [Debug
]. By delegating to Report
, we ensure
that the error is still formatted in a user-friendly way and the source
chain can be kept in these cases.
§Example
#[derive(thiserror::Error, thiserror_ext::ReportDebug)]
#[error("inner")]
struct Inner;
#[derive(thiserror::Error, thiserror_ext::ReportDebug)]
#[error("outer")]
struct Outer {
#[source]
inner: Inner,
}
let error = Outer { inner: Inner };
println!("{:?}", error);
§New type
Since the new type delegates its [Debug
] implementation to the original
error type, if the original error type derives ReportDebug
, the new type
will also behave the same.