Struct eyre::DefaultHandler
source · pub struct DefaultHandler { /* private fields */ }
Expand description
The default provided error report handler for eyre::Report
.
On nightly this supports conditionally capturing a std::backtrace::Backtrace
if the source
error did not already capture one.
Implementations§
source§impl DefaultHandler
impl DefaultHandler
sourcepub fn default_with(error: &(dyn StdError + 'static)) -> Box<dyn EyreHandler>
pub fn default_with(error: &(dyn StdError + 'static)) -> Box<dyn EyreHandler>
Manual hook which constructs DefaultHandler
s.
Details
When supplied to the set_hook
function, default_with
will cause eyre::Report
to use
DefaultHandler
as the error report handler.
If the auto-install
feature is enabled, and a user-provided hook for constructing
EyreHandlers
was not installed using set_hook
, DefaultHandler::default_with
is automatically installed as the hook.
Example
ⓘ
use eyre::{DefaultHandler, eyre, InstallError, Result, set_hook};
fn main() -> Result<()> {
install_default().expect("default handler inexplicably already installed");
Err(eyre!("hello from default error city!"))
}
fn install_default() -> Result<(), InstallError> {
set_hook(Box::new(DefaultHandler::default_with))
}