Skip to content

Commit 1c94153

Browse files
authored
fix: fallback to error code when message is unset (#328)
When the API return a `server_error`, it may not provide a message. This ensures that we print `server_none` instead of `None` when printing the exception.
1 parent 155a565 commit 1c94153

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

hcloud/_exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class HCloudException(Exception):
1010
class APIException(HCloudException):
1111
"""There was an error while performing an API Request"""
1212

13-
def __init__(self, code: int | str, message: str, details: Any):
14-
super().__init__(message)
13+
def __init__(self, code: int | str, message: str | None, details: Any):
14+
super().__init__(code if message is None and isinstance(code, str) else message)
1515
self.code = code
1616
self.message = message
1717
self.details = details

0 commit comments

Comments
 (0)