4 ms·
In SNAFU, you can add a Location [0] type to your error which will automatically capture that information when you add context to your error [0] https://docs.r
by shepmaster 3y ago
In SNAFU, you can add a Location [0] type to your error which will automatically capture that information when you add context to your error
[0] https://docs.rs/snafu/latest/snafu/struct.Location.html https://docs.rs/snafu/latest/snafu/struct.Location.html
- tasn 3y agoWe have a similar structure in our code. How does snafu get filename and line number when adding context? Context usually added like this: `some_error.context("bloop")`, no? Which can't get the line info, that's why we used a macro.
- shepmaster 3y agoYou will want to use `Location::caller` [0] instead of the `line` macro (and friends). You will need to annotate enough places with `#[track_caller]` so the location is correct. [0]: https://doc.rust-lang.org/std/panic/struct.Location.html#method.caller https://doc.rust-lang.org/std/panic/struct.Location.html#met...
- tasn 3y agoAh, gotcha! We are actually going to try what the sibling comment recommended. https://news.ycombinator.com/item?id=37235165 https://news.ycombinator.com/item?id=37235165