Added more error handling for ClientErrors while connecting with a wiki (due to Fandom issues)

This commit is contained in:
Frisk 2022-06-04 13:17:05 +02:00
parent 23b5a5db1c
commit 3c840b1d42
No known key found for this signature in database
GPG key ID: 213F7C15068AF8AC
2 changed files with 8 additions and 3 deletions

View file

@ -3,7 +3,6 @@ from setuptools import setup
setup( setup(
name='RcGcDw', name='RcGcDw',
version='1.14.0.1', version='1.14.0.1',
packages=[''],
url='https://gitlab.com/piotrex43/RcGcDw/', url='https://gitlab.com/piotrex43/RcGcDw/',
license='GNU GPLv3', license='GNU GPLv3',
author='Frisk', author='Frisk',
@ -12,5 +11,5 @@ setup(
keywords=['MediaWiki', 'recent changes', 'Discord', 'webhook'], keywords=['MediaWiki', 'recent changes', 'Discord', 'webhook'],
package_dir={"": "src"}, package_dir={"": "src"},
install_requires=["beautifulsoup4 >= 4.6.0", "requests >= 2.18.4", "schedule >= 0.5.0", "lxml >= 4.2.1"], 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"
) )

View file

@ -124,7 +124,13 @@ class Wiki(object):
request = self.api_request(self.construct_params(amount)) request = self.api_request(self.construct_params(amount))
except (ServerError, MediaWikiError): except (ServerError, MediaWikiError):
raise ConnectionError 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 raise
return request return request