mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-22 00:44:10 +00:00
Handle MW errors in the new handler as well
This commit is contained in:
parent
0b3a868640
commit
f33be9a127
|
@ -322,6 +322,7 @@ class Wiki:
|
|||
# any([True for k in request_data.keys() if k in ("error", "errors")])
|
||||
errors: list = request_data.get("errors", {}) # Is it ugly? I don't know tbh
|
||||
if errors:
|
||||
logger.error("MediaWiki error on request: {}".format(url))
|
||||
raise MediaWikiError(str(errors))
|
||||
warnings: list = request_data.get("warnings", {})
|
||||
if warnings:
|
||||
|
@ -398,9 +399,6 @@ class Wiki:
|
|||
except ValueError:
|
||||
logger.warning("ValueError when extracting JSON data on {url}".format(url=request.url))
|
||||
raise ServerError
|
||||
except MediaWikiError:
|
||||
logger.exception("MediaWiki error on request: {}".format(request.url))
|
||||
raise
|
||||
except KeyError:
|
||||
logger.exception("KeyError while iterating over json_path, full response: {}".format(request.json()))
|
||||
raise
|
||||
|
@ -485,7 +483,7 @@ class Wiki:
|
|||
try:
|
||||
request = await self.fetch_wiki(amount=amount)
|
||||
self.client.last_request = request
|
||||
except (aiohttp.ServerTimeoutError, asyncio.TimeoutError, WikiServerError, ServerError) as e:
|
||||
except (aiohttp.ServerTimeoutError, asyncio.TimeoutError, WikiServerError, ServerError, MediaWikiError) as e:
|
||||
self.statistics.update(Log(type=LogType.CONNECTION_ERROR, title=str(str(e.exception) if hasattr(e, "exception") else repr(e))))
|
||||
amount_of_failures = len(self.statistics.last_connection_failures()[0])
|
||||
if amount_of_failures < 2:
|
||||
|
|
Loading…
Reference in a new issue