Skip to content

Commit

Permalink
🐛 (api.py): Raise correct error when timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerka30 authored and tsoliver committed Aug 10, 2023
1 parent be97a4f commit 3c9dece
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions uptime_kuma_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,14 @@ def _get_event_data(self, event) -> Any:
return deepcopy(self._event_data[event].copy())

def _call(self, event, data=None) -> Any:
r = self.sio.call(event, data, timeout=self.timeout)
if isinstance(r, dict) and "ok" in r:
if not r["ok"]:
raise UptimeKumaException(r.get("msg"))
try:
r = self.sio.call(event, data, timeout=self.timeout)
r.pop("ok")
except socketio.exceptions.TimeoutError:
raise Timeout(f"Timed out while waiting for event {event}")
except Exception as e:
raise UptimeKumaException(r.get("msg"))

return r

# event handlers
Expand Down

0 comments on commit 3c9dece

Please sign in to comment.