Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions getstream/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class StreamException(Exception):
class StreamApiException(StreamException):
"""Raised on any HTTP 4xx/5xx response from the Stream API.

Raised with code=0 and message='failed to parse error response' when an
HTTP response was received but the body could not be parsed as an
APIError envelope; in that case ``__cause__`` carries the underlying
parse error.
Raised with code=0 and message='failed to parse error response: unexpected
server response code <status>' when an HTTP response was received but the
body could not be parsed as an APIError envelope; in that case ``__cause__``
carries the underlying parse error.
"""

def __init__(
Expand Down Expand Up @@ -205,7 +205,7 @@ def _fields_from_response(
{
"status_code": response.status_code,
"code": 0,
"message": "failed to parse error response",
"message": f"failed to parse error response: unexpected server response code {response.status_code}",
"exception_fields": {},
"unrecoverable": False,
"raw_response_body": raw_body,
Expand Down
5 changes: 4 additions & 1 deletion tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ def test_api_exception_unparseable_body_falls_back_per_spec_6_3():
exc = build_api_exception(response)
assert exc.status_code == 500
assert exc.code == 0
assert exc.message == "failed to parse error response"
assert (
exc.message
== "failed to parse error response: unexpected server response code 500"
)
assert exc.exception_fields == {}
assert exc.unrecoverable is False
assert exc.raw_response_body == "<html>upstream barfed</html>"
Expand Down
6 changes: 5 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading