add some error handling in json parsing
This commit is contained in:
parent
41968fe66b
commit
a48fcb096e
1 changed files with 7 additions and 3 deletions
|
@ -300,9 +300,13 @@ def get_toot_context(server, toot_id, toot_url):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if resp.status_code == 200:
|
if resp.status_code == 200:
|
||||||
|
try:
|
||||||
res = resp.json()
|
res = resp.json()
|
||||||
print(f"Got context for toot {toot_url}")
|
print(f"Got context for toot {toot_url}")
|
||||||
return (toot["url"] for toot in (res["ancestors"] + res["descendants"]))
|
return (toot["url"] for toot in (res["ancestors"] + res["descendants"]))
|
||||||
|
except Exception as ex:
|
||||||
|
print(f"Error parsing context for toot {toot_url}. Exception: {ex}")
|
||||||
|
return []
|
||||||
|
|
||||||
print(
|
print(
|
||||||
f"Error getting context for toot {toot_url}. Status code: {resp.status_code}"
|
f"Error getting context for toot {toot_url}. Status code: {resp.status_code}"
|
||||||
|
|
Loading…
Reference in a new issue