sidit77·3 yıl önce·discussYou 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(), } } }
sidit77·3 yıl önce·discussAny reason why you implemented your own proc macro instead of just using std::panic::Location::caller()? Right now I don't see the advantage of this crate.
sidit77·5 yıl önce·discussWhen implementing Display you only get access to an immutable reference to self, so the only possibly side effects are writes to global variables.