Skip to content
Snippets Groups Projects
Commit 6a5c6dd7 authored by Ben Morrice's avatar Ben Morrice
Browse files

Capture json.loads exceptions

parent 8a3b69dc
No related branches found
No related tags found
1 merge request!9Various improvements
......@@ -115,7 +115,11 @@ def get_token(ot):
if result.status_code != 200:
print("unable to auth, exiting")
sys.exit(1)
token = json.loads(result.content)["access_token"]
try:
token = json.loads(result.content)["access_token"]
except json.decoder.JSONDecodeError:
print("unable to auth, exiting")
sys.exit(1)
return token
......@@ -136,7 +140,12 @@ def get_upstream(token, feed):
packages = []
while True:
result = call_api(token, url, params={"limit": 100, "offset": offset})
j = json.loads(result.content)
try:
j = json.loads(result.content)
except json.decoder.JSONDecodeError:
# TODO: fix this?
print("Encountered an error retrieving upstream packages, exiting loop", flush=True)
return []
offset = j["pagination"]["offset"]
count = j["pagination"]["count"]
for p in j["body"]:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment