1 2 3 4 5 6 7 8 9 10 11 12 13
use std::error::Error; pub trait CatchError { fn catch(&self); } impl<E: Error> CatchError for Result<(), E> { fn catch(&self) { if let Err(e) = self { ::log::error!("{e}"); } } }