Skip to content

Commit 26ee370

Browse files
authored
fix(https_fn): pass message to HttpsError super().__init__ (fixes #314) (#315)
1 parent 4186454 commit 26ee370

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎src/firebase_functions/https_fn.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def __init__(
263263

264264
self._http_error_code = _error_code_map[code]
265265

266-
super().__init__()
266+
super().__init__(message)
267267

268268
def _as_dict(self) -> _HttpErrorWireFormat:
269269
if self.details is None:

‎tests/test_https_fn.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,16 @@ def init():
9696
decorated_func(request)
9797

9898
self.assertEqual("world", hello)
99+
100+
def test_https_error_passes_message_to_super(self):
101+
"""
102+
HttpsError should pass the message to the base Exception so that
103+
str(err) and err.args contain the message.
104+
"""
105+
err = https_fn.HttpsError(
106+
code=https_fn.FunctionsErrorCode.INVALID_ARGUMENT,
107+
message="something went wrong",
108+
)
109+
110+
self.assertEqual(str(err), "something went wrong")
111+
self.assertEqual(err.args, ("something went wrong",))

0 commit comments

Comments
 (0)