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

Use Mozilla documentation instead of httpstatuses.com for HTTP error reference #2768

Merged
merged 3 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ Traceback (most recent call last):
File "/Users/tomchristie/GitHub/encode/httpcore/httpx/models.py", line 837, in raise_for_status
raise HTTPStatusError(message, response=self)
httpx._exceptions.HTTPStatusError: 404 Client Error: Not Found for url: https://httpbin.org/status/404
For more information check: https://httpstatuses.com/404
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404
```

Any successful response codes will simply return `None` rather than raising an exception.
Expand Down
4 changes: 2 additions & 2 deletions httpx/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,12 +729,12 @@ def raise_for_status(self) -> None:
message = (
"{error_type} '{0.status_code} {0.reason_phrase}' for url '{0.url}'\n"
"Redirect location: '{0.headers[location]}'\n"
"For more information check: https://httpstatuses.com/{0.status_code}"
"For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/{0.status_code}"
)
else:
message = (
"{error_type} '{0.status_code} {0.reason_phrase}' for url '{0.url}'\n"
"For more information check: https://httpstatuses.com/{0.status_code}"
"For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/{0.status_code}"
)

status_class = self.status_code // 100
Expand Down
8 changes: 4 additions & 4 deletions tests/models/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_raise_for_status():
response.raise_for_status()
assert str(exc_info.value) == (
"Informational response '101 Switching Protocols' for url 'https://example.org'\n"
"For more information check: https://httpstatuses.com/101"
"For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/101"
)

# 3xx status codes are redirections.
Expand All @@ -114,7 +114,7 @@ def test_raise_for_status():
assert str(exc_info.value) == (
"Redirect response '303 See Other' for url 'https://example.org'\n"
"Redirect location: 'https://other.org'\n"
"For more information check: https://httpstatuses.com/303"
"For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/303"
)

# 4xx status codes are a client error.
Expand All @@ -125,7 +125,7 @@ def test_raise_for_status():
response.raise_for_status()
assert str(exc_info.value) == (
"Client error '403 Forbidden' for url 'https://example.org'\n"
"For more information check: https://httpstatuses.com/403"
"For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403"
)

# 5xx status codes are a server error.
Expand All @@ -136,7 +136,7 @@ def test_raise_for_status():
response.raise_for_status()
assert str(exc_info.value) == (
"Server error '500 Internal Server Error' for url 'https://example.org'\n"
"For more information check: https://httpstatuses.com/500"
"For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500"
)

# Calling .raise_for_status without setting a request instance is
Expand Down