jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/706702 )
Change subject: remove traceback for original exception for known API error codes 2 ......................................................................
remove traceback for original exception for known API error codes 2
also handle missingtitle for moves
Change-Id: I997e708b1815b3ea22704728b2589b9a11978c87 --- M pywikibot/site/_apisite.py 1 file changed, 20 insertions(+), 9 deletions(-)
Approvals: JJMC89: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py index 459aca6..33ada84 100644 --- a/pywikibot/site/_apisite.py +++ b/pywikibot/site/_apisite.py @@ -1478,7 +1478,9 @@ 'user': self.user(), } if err.code in self._dl_errors: - raise Error(self._dl_errors[err.code].format_map(errdata)) + raise Error( + self._dl_errors[err.code].format_map(errdata) + ) from None pywikibot.debug("revdelete: Unexpected error code '{}' received." .format(err.code), _logger) @@ -1714,7 +1716,7 @@
if 'spamblacklist' in result['edit']: raise SpamblacklistError( - page, result['edit']['spamblacklist']) + page, result['edit']['spamblacklist']) from None
if 'code' in result['edit'] and 'info' in result['edit']: pywikibot.error( @@ -1826,7 +1828,7 @@ except APIError as err: if err.code in self._mh_errors: on_error = self._mh_errors[err.code] - raise Error(on_error.format_map(errdata)) + raise Error(on_error.format_map(errdata)) from None
pywikibot.debug( "mergehistory: Unexpected error code '{code}' received" @@ -1871,6 +1873,7 @@ 'filetypemismatch': '[[{newtitle}]] file extension does not match content of ' '[[{oldtitle}]]', + 'missingtitle': "{oldtitle} doesn't exist", }
@need_right('move') @@ -1940,7 +1943,7 @@ break else: failed_page = newpage if on_error.on_new_page else page - raise on_error.exception(failed_page) + raise on_error.exception(failed_page) from None
errdata = { 'site': self, @@ -1951,7 +1954,7 @@ 'user': self.user(), }
- raise Error(on_error.format_map(errdata)) + raise Error(on_error.format_map(errdata)) from None
pywikibot.debug("movepage: Unexpected error code '{}' received." .format(err.code), @@ -2025,7 +2028,9 @@ 'user': self.user(), } if err.code in self._rb_errors: - raise Error(self._rb_errors[err.code].format_map(errdata)) + raise Error( + self._rb_errors[err.code].format_map(errdata) + ) from None pywikibot.debug("rollback: Unexpected error code '{}' received." .format(err.code), _logger) @@ -2102,7 +2107,9 @@ 'user': self.user(), } if err.code in self._dl_errors: - raise Error(self._dl_errors[err.code].format_map(errdata)) + raise Error( + self._dl_errors[err.code].format_map(errdata) + ) from None pywikibot.debug('delete: Unexpected error code {!r} received.' .format(err.code), _logger) @@ -2186,7 +2193,9 @@ 'user': self.user(), } if err.code in self._dl_errors: - raise Error(self._dl_errors[err.code].format_map(errdata)) + raise Error( + self._dl_errors[err.code].format_map(errdata) + ) from None pywikibot.debug('undelete: Unexpected error code {!r} received.' .format(err.code), _logger) @@ -2296,7 +2305,9 @@ 'user': self.user(), } if err.code in self._protect_errors: - raise Error(self._protect_errors[err.code].format_map(errdata)) + raise Error( + self._protect_errors[err.code].format_map(errdata) + ) from None pywikibot.debug("protect: Unexpected error code '{}' received." .format(err.code), _logger)
pywikibot-commits@lists.wikimedia.org