Skip to content

Commit d3f84eb

Browse files
committed
Handel JSON parsing errors
1 parent 74e0598 commit d3f84eb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

yeelib/bulbs.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,11 @@ def send_command(self, method, params):
7171
logger.exception("Connection error")
7272
self.socket = None
7373
else:
74-
response = yield from reader.readline()
74+
response = (yield from reader.readline()).decode()
7575
if response is not None:
7676
logger.debug("%s: ... %s",
77-
self.ip, response.decode().strip())
78-
return json.loads(response.decode())
77+
self.ip, response.strip())
78+
try:
79+
return json.loads(response)
80+
except ValueError:
81+
logger.exception("Could not read message: %s", response)

0 commit comments

Comments
 (0)