4 ms·
Panic location will only tell you where your program choked on an error, not where that error actually came from- there can be a very big difference when you ha
by ryukoposting 3y ago
Panic location will only tell you where your program choked on an error, not where that error actually came from- there can be a very big difference when you have a long chain of functions returning Result<_, Box<dyn Error>>
- sidit77 3y agoYou 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.