Skip to content

Commit

Permalink
fix: fallback to error code when message is unset (#328)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jooola authored Nov 27, 2023
1 parent 155a565 commit 1c94153
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hcloud/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class HCloudException(Exception):
class APIException(HCloudException):
"""There was an error while performing an API Request"""

def __init__(self, code: int | str, message: str, details: Any):
super().__init__(message)
def __init__(self, code: int | str, message: str | None, details: Any):
super().__init__(code if message is None and isinstance(code, str) else message)
self.code = code
self.message = message
self.details = details

0 comments on commit 1c94153

Please sign in to comment.