-
Notifications
You must be signed in to change notification settings - Fork 53
modernize error handling #88
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
Conversation
@rdelfin you might be interested in taking a look at this. |
Oooh this is nice! I'll be looking forwards to the merge. Using |
2dfe265
to
35bf144
Compare
Problem Currently, we do error handling with the `failure` crate which requires that users are aware of `failure` and use it in their library or application. Solution Switch error handling to use the `thiserror` crate which allows us to derive `std::error::Error` for our error type. Result This library's public API now uses `std::error::Error` in the `Result`s. This allows better composition within higher level libraries and applications.
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.
That blog post is great! Using thiserror my makes a lot of sense. It not showing up in the API is great. Thanks for linking it.
I can't really makes useful comments on the actual errors as I've never done any bpf things. As for naming, being consistent would be great but I don't know which style you should go with.
sorry for the slow reply -- I haven't written any Rust for like a year and so I'm unlikely to be that helpful :). this seems reasonable to me! |
Fixing some of the error names for consistency, I will merge following successful CI run. |
Problem
Currently, we do error handling with the
failure
crate whichrequires that users are aware of
failure
and use it in theirlibrary or application.
Solution
Switch error handling to use the
thiserror
crate which allows usto derive
std::error::Error
for our error type.Result
This library's public API now uses
std::error::Error
in theResult
s. This allows better composition within higher levellibraries and applications.
This will be a breaking change to the existing API.
Notes to reviewers
Some of the
Error
variants might need better naming / error messages, we should try to get naming correct on this pass to avoid additional breaking changes.Particular areas to focus on:
This PR would replace #81 - my understanding is that
anyhow
would be appropriate for an application, but we should usethiserror
within libraries.Came across this post, which inspired me to convert to
thiserror
:https://nick.groenen.me/posts/rust-error-handling/