4 ms·
You can just pass the location up the stack alongside the type erased error. #[derive(Debug)] pub struct LocatedError { inner: Box<dyn Error + 'stati
by sidit77 3y ago
You can just pass the location up the stack alongside the type erased error.
#[derive(Debug)]
pub struct LocatedError {
inner: Box<dyn Error + 'static>,
location: &'static Location<'static>
}
impl<E: Error + 'static> From<E> for LocatedError {
#[track_caller]
fn from(value: E) -> Self {
Self {
inner: Box::new(value),
location: Location::caller(),
}
}
}
- ryukoposting 3y agoSure, but I think the point of this crate is that it removes this boilerplate.