Skip to content

Commit

Permalink
Guard against malformed json
Browse files Browse the repository at this point in the history
Signed-off-by: Francis Giraldeau <[email protected]>
  • Loading branch information
giraldeau committed Dec 27, 2017
1 parent b993c8d commit 3d1caab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion chgrs/chgrs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ class AddEnergieAPIv11(BaseAPI):
if r.status_code != 200:
print("error: fetch failed {}".format(r.status_code))
return False
self.data = r.json()
try:
self.data = r.json()
except:
print("Failed to load json data")
print(r.text)
return False
return True

apis = {
Expand Down

0 comments on commit 3d1caab

Please sign in to comment.