Print error on invalid json (#263)

This commit is contained in:
Pascal Vizeli 2017-11-30 20:23:20 +01:00 committed by GitHub
parent 747810b729
commit 8f94b4d63f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,10 +17,12 @@ _LOGGER = logging.getLogger(__name__)
def json_loads(data):
"""Extract json from string with support for '' and None."""
if not data:
return {}
try:
return json.loads(data)
except json.JSONDecodeError:
return {}
raise RuntimeError("Invalid json")
def api_process(method):