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
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue