From 20195f3ce56c3a38ba3550d1967b0d405fd0d2f4 Mon Sep 17 00:00:00 2001 From: jo Date: Mon, 27 Nov 2023 14:13:53 +0100 Subject: [PATCH] fix: fallback to error code when message is unset --- hcloud/_exceptions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hcloud/_exceptions.py b/hcloud/_exceptions.py index 51e3745..877083f 100644 --- a/hcloud/_exceptions.py +++ b/hcloud/_exceptions.py @@ -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