From 3d1caab4af8efde46da2f75a180aaf3a59c9eabe Mon Sep 17 00:00:00 2001 From: Francis Giraldeau Date: Wed, 27 Dec 2017 15:46:27 -0500 Subject: [PATCH] Guard against malformed json Signed-off-by: Francis Giraldeau --- chgrs/chgrs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chgrs/chgrs b/chgrs/chgrs index 54806b7..73722b2 100755 --- a/chgrs/chgrs +++ b/chgrs/chgrs @@ -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 = {