Skip to content

Commit 7273927

Browse files
author
Andrew Smith
authored
fix: exceptions now has message in dictionary (#16)
2 parents 4e18712 + 07a813a commit 7273927

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

supafunc/errors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class FunctionsApiErrorDict(TypedDict):
1212
class FunctionsError(Exception):
1313
def __init__(self, message: str, name: str, status: int) -> None:
1414
super().__init__(message)
15+
self.message = message
1516
self.name = name
1617
self.status = status
1718

tests/_async/test_function_client.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,17 @@ async def test_invoke_with_non_200_response():
6868
return_value=Response(404),
6969
side_effect=FunctionsHttpError("Http error!"),
7070
)
71-
with pytest.raises(FunctionsHttpError, match=r"Http error!"):
71+
with pytest.raises(FunctionsHttpError, match=r"Http error!") as exc:
7272
await function_client().invoke(function_name="hello-world")
73+
assert exc.value.message == "Http error!"
74+
75+
76+
async def test_relay_error_message():
77+
async with respx.mock:
78+
respx.post(f"{FUNCTIONS_URL}/hello-world").mock(
79+
return_value=Response(200, headers={"x-relay-header": "true"}),
80+
side_effect=FunctionsRelayError("Relay error!"),
81+
)
82+
with pytest.raises(FunctionsRelayError, match=r"Relay error!") as exc:
83+
await function_client().invoke(function_name="hello-world")
84+
assert exc.value.message == "Relay error!"

0 commit comments

Comments
 (0)