Better error handling

This commit is contained in:
Frisk 2020-08-19 01:04:41 +02:00
parent 443bb8e5af
commit 150fc6c0d5
No known key found for this signature in database
GPG key ID: 213F7C15068AF8AC

View file

@ -218,8 +218,11 @@ async def scan_group(group: str):
continue # ignore this wiki if it throws errors
try:
recent_changes_resp = await wiki_response.json()
if "error" in recent_changes_resp or "errors" in recent_changes_resp:
error = recent_changes_resp.get("error", recent_changes_resp["errors"])
if not isinstance(recent_changes_resp, dict):
logger.error(f"recent_changes_resp has a bad type, found {type(recent_changes_resp)}, __repr__ here: {recent_changes_resp}.")
raise TypeError
if "errors" in recent_changes_resp:
error = recent_changes_resp.get('errors')
if error["code"] == "readapidenied":
await local_wiki.fail_add(queued_wiki.url, 410)
continue
@ -353,6 +356,9 @@ async def discussion_handler():
except aiohttp.ContentTypeError:
logger.exception("Wiki seems to be resulting in non-json content.")
continue
except asyncio.TimeoutError:
logger.debug("Timeout on reading JSON of discussion post feeed.")
continue
except:
logger.exception("On loading json of response.")
continue