4 ms·
We 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("
by tasn 3y ago
We 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