4 ms·
I 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,
by JoelJacobson 3y ago
I 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.