🐛 (api.py): Raise correct error when timeout

This commit is contained in:
Raphael Hien 2023-08-10 11:45:23 +02:00
parent be97a4fd8f
commit 677de72b2b
No known key found for this signature in database
GPG key ID: 8584D9306628BDC4

View file

@ -500,7 +500,10 @@ class UptimeKumaApi(object):
return deepcopy(self._event_data[event].copy())
def _call(self, event, data=None) -> Any:
r = self.sio.call(event, data, timeout=self.timeout)
try:
r = self.sio.call(event, data, timeout=self.timeout)
except socketio.exceptions.TimeoutError:
raise Timeout(f"Timed out while waiting for event {event}")
if isinstance(r, dict) and "ok" in r:
if not r["ok"]:
raise UptimeKumaException(r.get("msg"))