Neohub can return invalid JSON. Assume that command failed.

E.g.

{"error":"Invalid argument to SET_TEMP_FORMAT, should be "C" or "F" "}

Correct JSON would be
{"error":"Invalid argument to SET_TEMP_FORMAT, should be \"C\" or \"F\" "}
This commit is contained in:
Andrius Štikonas 2020-11-20 23:26:45 +00:00
parent 175497b15b
commit 6973ec8d17
1 changed files with 7 additions and 1 deletions

View File

@ -33,7 +33,13 @@ class NeoHub:
writer.close()
await writer.wait_closed()
reply = json.loads(json_string)
try:
reply = json.loads(json_string)
except json.decoder.JSONDecodeError:
if expected_reply is None:
raise(e)
else:
return False
if expected_reply is None:
return reply