Author of `wherr` here.
> I think the disadvantage you mention is actually an advantage. I would probably want this to propagate alongside other `track_caller`'s since anyone using `track_caller` is "in the know" about where that error should be appearing to come from.
I've now read about `#[track_caller]`, and that's my conclusion too. For those who haven't heard about `#[track_caller]` like myself, I can recommend this page: https://blog.rust-lang.org/2020/08/27/Rust-1.46.0.html#track...
> TBH I had assumed this crate was using the `#[track_caller]` attribute.
TBH, having read about the `#[track_caller]` attribute, I'm starting to think the crate should use it.
If you and/or @afdbcreid would be interested in working with me on a new implementation of the `wherr` crate that uses the `#[track_caller]` approach instead, please contact me at joel at compiler dot org. Hope to hear from you!
> The main downside I see is that if I manually construct the error type I'll miss that place, unless the constructor of that error also tracks the caller.
You mean, we would need to make sure the error type is always created via a new() constructor method, and that the new() method also has the `#[track_caller]` attribute? Something like this?
impl MyError {
#[track_caller]
pub fn new<E: StdError + Send + Sync + 'static>(error: E) -> Self {
Self {
error: Box::new(error),
location: Location::caller(),
}
}
}