mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-23 00:54:09 +00:00
Better error handling
This commit is contained in:
parent
443bb8e5af
commit
150fc6c0d5
10
src/bot.py
10
src/bot.py
|
@ -218,8 +218,11 @@ async def scan_group(group: str):
|
||||||
continue # ignore this wiki if it throws errors
|
continue # ignore this wiki if it throws errors
|
||||||
try:
|
try:
|
||||||
recent_changes_resp = await wiki_response.json()
|
recent_changes_resp = await wiki_response.json()
|
||||||
if "error" in recent_changes_resp or "errors" in recent_changes_resp:
|
if not isinstance(recent_changes_resp, dict):
|
||||||
error = recent_changes_resp.get("error", recent_changes_resp["errors"])
|
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":
|
if error["code"] == "readapidenied":
|
||||||
await local_wiki.fail_add(queued_wiki.url, 410)
|
await local_wiki.fail_add(queued_wiki.url, 410)
|
||||||
continue
|
continue
|
||||||
|
@ -353,6 +356,9 @@ async def discussion_handler():
|
||||||
except aiohttp.ContentTypeError:
|
except aiohttp.ContentTypeError:
|
||||||
logger.exception("Wiki seems to be resulting in non-json content.")
|
logger.exception("Wiki seems to be resulting in non-json content.")
|
||||||
continue
|
continue
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
logger.debug("Timeout on reading JSON of discussion post feeed.")
|
||||||
|
continue
|
||||||
except:
|
except:
|
||||||
logger.exception("On loading json of response.")
|
logger.exception("On loading json of response.")
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue