3 ms·
Note that some things, like anyhow do create backtraces (if the feature is enabled) when they are created, including by `?` auto-converting into them and includ
by dathinab 3y ago
Note that some things, like anyhow do create backtraces (if the feature is enabled) when they are created, including by `?` auto-converting into them and including chaining the backtrace from the error they where created from.
Through also note that async code has ... not so nice backtraces, for now, even if you only care about the calling location.
- ahahahahah 3y agoanyhow's backtraces are from where the error is created. This isn't necessarily the same as the path through which it is propagated with "?". honestly, i think the former is probably more valuable, but i really don't know.
- JoelJacobson 3y agoI like `anyhow`, it's a great! But it doesn't help if the existing error, wherever it is created, doesn't already use `anyhow`. For errors that you can't find, then adding the `#[wherr]` macro to the functions, could possibly be faster, than changing all lines of code where errors are created, to use `anyhow`, to find the error. `#[wherr]` is one line per function, whereas `anyhow`'s `.context()?` is one line per error. Also, a backtrace could be more expensive than just wrapping the error once with file and line information as `wherr` does, and the backtrace might be overkill, if only interested in finding the line of code where the error is created.
- IshKebab 3y agoYou don't need to use `.context()` to get the backtrace.
- dathinab 3y agoThe point I was trying to make is that when (and only when) `?` creates an anyhow error through automatic conversion from a different error it will add a backtrace at that point, additional to any backtrace the original error might have.