-
Notifications
You must be signed in to change notification settings - Fork 1.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
Error handling needs an update #72
Comments
I beat your dfc to the github registration finish line. Yay for me, but bad https://github.com/nlopes/slack/blob/master/admin.go#L21 is a good example That returns an error if something goes wrong, or it returns an error if @dfc https://github.com/dfc has a good set of examples on his blog What do you think? — |
Oh, sorry! I'll correct that. On 9 May 2016 04:50:11 CEST, Douglas Calvert notifications@github.com wrote:
Sent from my Android device with K-9 Mail. Please excuse my brevity. |
One vote for @flexd |
https://github.com/nlopes/slack/blob/master/admin.go#L21 is a good example of bad errors.
That returns an error if something goes wrong, or it returns an error if the API gives a error. How do we differentiate between those two states? I can't show the API error to a user, because if it's a JSON Unmarshal error that's not a good idea. And currently the only way of checking would be to check if the error message contains a string, which is a bad idea.
Dave Cheney has a good set of examples on his blog http://dave.cheney.net/2016/04/27/dont-just-check-errors-handle-them-gracefully and has also made a very nice package that fits what he is saying https://github.com/pkg/errors
What do you think?
Edit: I accidentally the wrong dfc.
The text was updated successfully, but these errors were encountered: