pub trait ErrorExt {
// Required method
fn report(&self) -> ErrorReport<'_>;
}Expand description
Extension trait for std::error::Error.
This trait is implemented for all types that implement Error,
providing additional methods for working with errors.
§Example
use std::error::Error;
use scoped_error::ErrorExt;
fn handle_error(e: impl Error + 'static) {
let report = e.report();
println!("{}", report);
}Required Methods§
Sourcefn report(&self) -> ErrorReport<'_>
fn report(&self) -> ErrorReport<'_>
Generate a formatted error report for this error.
The report includes the error message and all causes in the chain, formatted for human readability.
§Example
use scoped_error::{Error, expect_error, ErrorExt};
let result: Result<(), Error> = expect_error("Outer", || {
Err("Inner")?;
Ok(())
});
if let Err(e) = result {
println!("{}", e.report());
}