try except block missing around a json.loads call
authordurandn
Tue, 02 Aug 2016 11:13:52 +0200
changeset 96 09b2da30cd93
parent 95 54d8dab80297
child 97 f747c112e8f4
try except block missing around a json.loads call
src/iconolab/models.py
--- a/src/iconolab/models.py	Mon Aug 01 14:19:36 2016 +0200
+++ b/src/iconolab/models.py	Tue Aug 02 11:13:52 2016 +0200
@@ -310,8 +310,12 @@
                         "format": "json"
                 }
             )
-            results = json.loads(dbpedia_resp.text).get("results", {})
-            variable_bindings = results.get("bindings")
+            try:
+                results = json.loads(dbpedia_resp.text).get("results", {})
+            except:
+                # if error with json, results is empty
+                results = {}
+            variable_bindings = results.get("bindings", None)
             if variable_bindings:
                 label_json = variable_bindings.pop()
             else: