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

Return an error object on connection failure #9

Closed
kevva opened this issue Oct 13, 2014 · 4 comments · Fixed by #10
Closed

Return an error object on connection failure #9

kevva opened this issue Oct 13, 2014 · 4 comments · Fixed by #10

Comments

@kevva
Copy link
Contributor

kevva commented Oct 13, 2014

https://github.com/sindresorhus/got/blob/master/index.js#L64. Could set a custom property (.resCode) with the error code and supply a user friendly error message like Couldn't connect to http://github.com (code 500).

The resCode property would need to be well documented since many will want too look for it.

@sindresorhus
Copy link
Owner

Could be either resCode/statusCode/code. What are others using?

@kevva
Copy link
Contributor Author

kevva commented Oct 13, 2014

statusCode is what I meant ;p. But code is probably better. Don't know what others are using or if anyone is actually setting a custom property. Most authors probably just returns the status as the error message.

@floatdrop
Copy link
Contributor

I stumbled on destroying response object before calling cb - it cleans all data, that was attached to 4xx response (it was JSON with errors). It some how connected to this issue - returned response object is destroyed.

Should this behavior be fixed as well?

@sindresorhus
Copy link
Owner

Yes

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

Successfully merging a pull request may close this issue.

3 participants