Skip to content

Commit

Permalink
Handel JSON parsing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Jan 7, 2018
1 parent 74e0598 commit d3f84eb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions yeelib/bulbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ def send_command(self, method, params):
logger.exception("Connection error")
self.socket = None
else:
response = yield from reader.readline()
response = (yield from reader.readline()).decode()
if response is not None:
logger.debug("%s: ... %s",
self.ip, response.decode().strip())
return json.loads(response.decode())
self.ip, response.strip())
try:
return json.loads(response)
except ValueError:
logger.exception("Could not read message: %s", response)

0 comments on commit d3f84eb

Please sign in to comment.