Skip to content

Commit

Permalink
Handle JSON error.
Browse files Browse the repository at this point in the history
  • Loading branch information
3asm committed Feb 9, 2024
1 parent 87de760 commit 38d4f8a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pychrome/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
from .tab import *
from .exceptions import *

__version__ = "0.2.5"
__version__ = "0.2.6"
7 changes: 6 additions & 1 deletion pychrome/tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ def _recv_loop(self):
if self.debug: # pragma: no cover
print("< RECV %s" % message_json)

message = json.loads(message_json)
try:
message = json.loads(message_json)
except json.decoder.JSONDecodeError:
logger.error("Error decoding message: `%s`", message_json, exc_info=True)
return

except websocket.WebSocketTimeoutException:
continue
except (websocket.WebSocketException, OSError):
Expand Down

0 comments on commit 38d4f8a

Please sign in to comment.