Trait miette::ReportHandler [−][src]
pub trait ReportHandler: Any + Send + Sync {
fn debug(
&self,
error: &(dyn Diagnostic + 'static),
f: &mut Formatter<'_>
) -> Result;
fn display(
&self,
error: &(dyn StdError + 'static),
f: &mut Formatter<'_>
) -> Result { ... }
fn track_caller(&mut self, location: &'static Location<'static>) { ... }
}
Expand description
Error Report Handler trait for customizing miette::Report
Required methods
fn debug(
&self,
error: &(dyn Diagnostic + 'static),
f: &mut Formatter<'_>
) -> Result
fn debug(
&self,
error: &(dyn Diagnostic + 'static),
f: &mut Formatter<'_>
) -> Result
Define the report format
Used to override the report format of miette::Report
Example
use miette::Diagnostic;
use miette::ReportHandler;
use indenter::indented;
pub struct Handler;
impl ReportHandler for Handler {
fn debug(
&self,
error: &(dyn Diagnostic + 'static),
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
use core::fmt::Write as _;
if f.alternate() {
return core::fmt::Debug::fmt(error, f);
}
write!(f, "{}", error)?;
Ok(())
}
}
Provided methods
Override for the Display
format
fn track_caller(&mut self, location: &'static Location<'static>)
fn track_caller(&mut self, location: &'static Location<'static>)
Store the location of the caller who constructed this error report