From 3c840b1d42a1233071510ea7848a7dfee19e8a20 Mon Sep 17 00:00:00 2001 From: Frisk Date: Sat, 4 Jun 2022 13:17:05 +0200 Subject: [PATCH] Added more error handling for ClientErrors while connecting with a wiki (due to Fandom issues) --- setup.py | 3 +-- src/wiki.py | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 24fbb7e..701a27b 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,6 @@ from setuptools import setup setup( name='RcGcDw', version='1.14.0.1', - packages=[''], url='https://gitlab.com/piotrex43/RcGcDw/', license='GNU GPLv3', author='Frisk', @@ -12,5 +11,5 @@ setup( keywords=['MediaWiki', 'recent changes', 'Discord', 'webhook'], package_dir={"": "src"}, install_requires=["beautifulsoup4 >= 4.6.0", "requests >= 2.18.4", "schedule >= 0.5.0", "lxml >= 4.2.1"], - python_requires="3.7" + python_requires=">=3.7" ) diff --git a/src/wiki.py b/src/wiki.py index b01dd23..ea74c0b 100644 --- a/src/wiki.py +++ b/src/wiki.py @@ -124,7 +124,13 @@ class Wiki(object): request = self.api_request(self.construct_params(amount)) except (ServerError, MediaWikiError): raise ConnectionError - except (ClientError, KeyError, BadRequest): + except ClientError as e: + if settings.get("error_tolerance", 0) > 1: + logger.error("When running RcGcDw received a client error that would indicate RcGcDw's mistake. However since your error_tolerance is set to a value higher than one we are going to log it and ignore it. If this issue persists, please check if the wiki still exists and you have latest RcGcDw version. Returned error: {}".format(e)) + raise ConnectionError + else: + raise + except (KeyError, BadRequest): raise return request