Commit 30417fa3 authored by Federico Sismondi's avatar Federico Sismondi

Update() catch errors when we receive empty or non json content

parent 1c76e0c8
......@@ -59,8 +59,11 @@ def get_data_from_weather_service():
except (requests.exceptions.ConnectTimeout, requests.exceptions.ConnectionError):
logger.info('Could not weather reach service')
return None
weather_data = {k: v for k, v in r.json().items() if k in dump_keys}
try:
weather_data = {k: v for k, v in r.json().items() if k in dump_keys}
except json.decoder.JSONDecodeError as e:
logger.error("Got something that doesnt look like a json: {}".format(r.content))
return None
return weather_data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment