Function spirit::error::log_errors [−][src]
pub fn log_errors<R, F>(target: &str, f: F) -> Result<R, AnyError> where
F: FnOnce() -> Result<R, AnyError>,
Expand description
A wrapper around a fallible function, logging any returned errors.
The errors will be logged in the provided target. You may want to provide module_path!
as the
target.
If the error has multiple levels (causes), they are printed in multi-line fashion, as multiple separate log messages.
Examples
use err_context::prelude::*;
use spirit::AnyError;
use spirit::error;
let result = error::log_errors(module_path!(), || {
try_to_do_stuff().context("Didn't manage to do stuff")?;
Ok(())
});