Skip to content

Commit

Permalink
better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlt8 committed Sep 3, 2023
1 parent 7d84dd9 commit 080f7a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/wyzebridge/wyze_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ def get_events(self, macs: Optional[list] = None, last_ts: int = 0):
except wyzecam.api.RateLimitError as ex:
logger.error(f"[EVENTS] RateLimitError: {ex}, cooling down.")
return ex.reset_by, []
except (wyzecam.api.WyzeAPIError, ValueError) as ex:
except Exception as ex:
logger.error(f"[API] ERROR - {ex}")
return time() + 60, []
return time() + 120, []

@authenticated
def set_device_info(self, cam: WyzeCamera, params: dict):
Expand Down
5 changes: 3 additions & 2 deletions app/wyzebridge/wyze_control.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import contextlib
import socket
from datetime import datetime, timedelta
from multiprocessing import Queue
from queue import Empty, Full
from queue import Empty
from re import findall
from typing import Any, Optional

Expand Down Expand Up @@ -274,6 +273,8 @@ def send_tutk_msg(sess: WyzeIOTCSession, cmd: tuple | str, log: str = "info") ->
return _response(resp, res, params, log)
except Empty:
return _response(resp, log=log)
except tutk_protocol.TutkWyzeProtocolError as ex:
return resp | _error_response(cmd, tutk_protocol.TutkWyzeProtocolError(ex))
except Exception as ex:
return resp | _error_response(cmd, ex)

Expand Down

0 comments on commit 080f7a3

Please sign in to comment.