Skip to content

Commit

Permalink
Fix JSONDecodeError not being caught when processing SPARQL query res…
Browse files Browse the repository at this point in the history
…ults
  • Loading branch information
michaelnchin committed Feb 16, 2022
1 parent b5d1885 commit 5a66e61
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/graph_notebook/magics/graph_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,11 @@ def sparql(self, line='', cell='', local_ns: dict = None):

query_res = self.client.sparql(cell, path=path, headers=headers)
query_res.raise_for_status()
results = query_res.json()
store_to_ns(args.store_to, results, local_ns)
try:
res = query_res.json()
except JSONDecodeError:
res = query_res.content.decode('utf-8')
store_to_ns(args.store_to, res, local_ns)
results = query_res.json()
except Exception:
results = query_res.content.decode('utf-8')
store_to_ns(args.store_to, results, local_ns)

if not args.silent:
# Assign an empty value so we can always display to table output.
Expand Down

0 comments on commit 5a66e61

Please sign in to comment.