Skip to content

Commit 29ee837

Browse files
authored
Error with error code without response
1 parent f7e3daf commit 29ee837

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

coc/errors.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,14 @@ class HTTPException(ClashOfClansException):
5353
__slots__ = ("response", "status", "message", "reason", "_data")
5454

5555
def _from_response(self, response, data):
56-
self.response = response
57-
self.status = response.status
56+
if isinstance(response, int):
57+
self.status = response
58+
self.response = None
59+
elif isinstance(response, ClientResponse):
60+
self.response = response
61+
self.status = response.status
62+
else:
63+
self.response = self.status = None
5864

5965
if isinstance(data, dict):
6066
self.reason = data.get("reason", "Unknown")
@@ -73,7 +79,7 @@ def _from_response(self, response, data):
7379
super().__init__(fmt.format(self))
7480

7581
def __init__(self, response=None, data=None):
76-
if isinstance(response, ClientResponse):
82+
if isinstance(response, (ClientResponse, int)):
7783
self._from_response(response, data)
7884
else:
7985
self.response = None

0 commit comments

Comments
 (0)