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

Improve HTTPError messages #333

Merged
merged 2 commits into from
May 4, 2021
Merged

Conversation

sholladay
Copy link
Collaborator

@sholladay sholladay commented Apr 4, 2021

This PR aims to provide a clearer error message to the user when an HTTPError occurs, by adding a description and showing both the status code and status text, when available.

Perhaps the best example of how this helps is where the response has an unusual status code, such as 0, but there is no status text, as is the case when HTTP/2 is being used.

Before:

HTTPError: 0

After:

HTTPError: Request failed with status 0

Happy to bikeshed the phrasing. Could change "failed with status" to "failed with response status", for example. Also on the fence about "an unknown error" vs "an unknown status" vs "an unknown response error", etc.

@sindresorhus
Copy link
Owner

HTTPError: Request failed with status 0

Maybe: HTTPError: Request failed with status code 0?

@sholladay
Copy link
Collaborator Author

Maybe: HTTPError: Request failed with status code 0?

Done.

@sholladay sholladay changed the title Improve HTTP error messages Improve HTTPError messages May 4, 2021
@sholladay
Copy link
Collaborator Author

@sindresorhus I fixed the merge conflicts.

@sindresorhus sindresorhus merged commit ca098f8 into sindresorhus:main May 4, 2021
@sholladay sholladay deleted the better-errors branch May 4, 2021 05:23
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 this pull request may close these issues.

None yet

2 participants