sources: fail gracefully when a source returns invalid JSON

Include the actual output of the source to help debugging.
This commit is contained in:
Lars Karlitski 2020-01-04 02:03:52 +02:00 committed by Tom Gundersen
parent ef7f17d95b
commit 02ad4e3810

View file

@ -26,7 +26,10 @@ class SourcesServer:
encoding="utf-8",
check=False)
return json.loads(r.stdout)
try:
return json.loads(r.stdout)
except ValueError:
return {"error": f"source returned malformed json: {r.stdout}"}
def _dispatch(self, sock):
msg, addr = sock.recvfrom(8182)