-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Update error handling as per Go 1.13 guidelines #1854
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1854 +/- ##
==========================================
+ Coverage 97.63% 97.64% +0.01%
==========================================
Files 105 105
Lines 6720 6762 +42
==========================================
+ Hits 6561 6603 +42
Misses 86 86
Partials 73 73
Continue to review full report at Codecov.
|
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.
Thank you, @mbalayil !
Please address the comments below.
Have updated the PR with more tests to improve coverage. Please take a look. |
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.
Thank you, @mbalayil !
LGTM.
Awaiting second LGTM before merging.
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.
💙
Thank you, @wesleimp! @willnorris - are you OK with this implementation? I'll wait until we hear from you... no rush... I just want to make sure since you had some comments on the thread. |
My biggest concern, just looking at this from a high level, is that this is a LOT of work and extra code just to be able to call The whole point of the new go1.13 error handling is that the I really appreciate all the effort @mbalayil put into this... really, I do. But looking at what it ended up taking in the end, I'm not sure that this is the right solution for this problem. (Unless there's some other use case that this is satisfying, outside of those two test cases.) |
Correct me if I'm wrong, @willnorris , but won't the availability of the In other words, doesn't the work here make error handler easier for future users of this package (and also make the usage more inline with the Go 1.13 Error Handling blog post)? |
Yeah, that's a good point. For the sentinel errors we have, I think that will be very useful (but also doesn't require a custom |
So do you think it would be more useful without the equality checks? Or should we run with this for awhile until we get feedback and then adjust accordingly? |
Looking more at the examples I was concerned about, they seem to be more limited than I thought. I was mostly focusing on the I guess I'd need to look at some more real-world errors to see how likely it would be for people to really be doing equality checks. My guess is that most go-github users that want to wrap our errors and eventually test for error types will use I know that doesn't directly answer your question, but I guess I'm discovering that my once somewhat-strongly-held view is softening considerably, so I can go either way on this now. |
OK, sounds good. Thanks, Will! |
Fixes 1846
README.md
to reflect that it is no longer Go 1.9 that we require, but instead we need a minimum of Go 1.13.reflect.DeepEqual
witherrors.Is
in all the affected tests.Is(error) bool
interface for all the required errors (ErrorResponse
,RateLimitError
,AcceptedError
andAbuseRateLimitError
). All the individual fields are directly compared. However, for the*http Response
field, onlyStatusCode
is being compared. If the other fields of thehttp.Response
struct need to be compared, please let me know.