-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Improve error handling in RPC package #187
Conversation
8587408
to
ffa3449
Compare
@zenhack I just rebased against |
@zenhack Re your question about quotes (can't seem to reply for some odd reason):
tl;dr: it was a judgement call about readability. Outputs should be identical, though, and we can revert if you prefer. |
But you can also use a |
Oh, I didn't realize that. Makes sense.
This sounds like our winner. Will push changes shortly. |
On several occasions I have found myself wanting to inspect RPC exceptions to control execution flow, in particular via functions such as
errors.Is
orerrors.As
. Currently, errors are collapsed when composed, making them difficult to inspect.This PR is an incremental attempt at improving error composition in the code base. It exports the
errors.Error
type, enhances it with anUnwrap()
method to make it compatible with the standard libraryerrors
package, and replaces%v
formatting directives with%w
andfmt.Errorf
.In addition to making errors more interpretable for the user, the resulting code is much more readable IMHO.