-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use anyhow for error handling #249
Conversation
Note: For debugging of errors, if messages aren't entirely obvious, we could also provide a debug build of tealdeer with
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Some things I found:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a couple of small talking points :)
Honestly, it feels so much better to read the word context
when, well, adding context to an error instead of having this ugly map_err
. I really hope benchmarks don't bear any surprises :^)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a couple of small talking points :)
Honestly, it feels so much better to read the word context
when, well, adding context to an error instead of having this ugly map_err
. I really hope benchmarks don't bear any surprises :^)
It might also be worth it to inspect all uses of |
I didn't really find problematic unwraps outside of tests, except for that unzip issue that popped up in that other issue. However, let's fix that separately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
everything looks good to me, I am building the benchmark docker right now!
Let me know if it makes a difference! The only place that could make a difference in my eyes is the replacement of the |
Okay so this took longer than I hoped it would. In the docker image, everything is within measurement error. On my machine, the anyhow version is anywhere from 0.2 to 0.7 ms slower than main (around 8 to 9 ms usually) on a cold disk cache. Without clearing caches, both are too fast to measure / too fast to factor out system noise. I am willing to take the performance "hit", I really like |
Use anyhow instead of custom error types and strings for error handling. This should give us "caused by" style traces when an error occurs.
Before:
And after:
PR summary:
We're doing something right 😉