Skip to content
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

Closed
flexd opened this issue May 8, 2016 · 3 comments
Closed

Error handling needs an update #72

flexd opened this issue May 8, 2016 · 3 comments

Comments

@flexd
Copy link
Contributor

flexd commented May 8, 2016

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.

@dfc
Copy link

dfc commented May 9, 2016

I beat your dfc to the github registration finish line. Yay for me, but bad
if you were expecting a response. I just wanted to make sure you knew that
@mention didn't hit the right inbox...
On May 8, 2016 12:14, "Kristoffer Berdal" notifications@github.com wrote:

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.

@dfc https://github.com/dfc 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?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/nlopes/slack/issues/72

@flexd
Copy link
Contributor Author

flexd commented May 9, 2016

Oh, sorry! I'll correct that.

On 9 May 2016 04:50:11 CEST, Douglas Calvert notifications@github.com wrote:

I beat your dfc to the github registration finish line. Yay for me, but
bad
if you were expecting a response. I just wanted to make sure you knew
that
@mention didn't hit the right inbox...
On May 8, 2016 12:14, "Kristoffer Berdal" notifications@github.com
wrote:

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.

@dfc https://github.com/dfc 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?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/nlopes/slack/issues/72


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
https://github.com/nlopes/slack/issues/72#issuecomment-217765903

Sent from my Android device with K-9 Mail. Please excuse my brevity.

@nguyendangminh
Copy link

One vote for @flexd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants