sidit77·vor 3 Jahren·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·vor 3 Jahren·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·vor 5 Jahren·discussWhen implementing Display you only get access to an immutable reference to self, so the only possibly side effects are writes to global variables.