jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/965058 )
Change subject: Make exception about missing mediainfo more friendly ......................................................................
Make exception about missing mediainfo more friendly
Before throwing, re-use the pageid of the file to avoid exception saying "Entity '-1' ..."
Also don't show the KeyError traceback.
Change-Id: I1a130419477960856b6f976762a128d100eb43a6 --- M pywikibot/page/_wikibase.py 1 file changed, 18 insertions(+), 2 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page/_wikibase.py b/pywikibot/page/_wikibase.py index 5141e00..7f098f8 100644 --- a/pywikibot/page/_wikibase.py +++ b/pywikibot/page/_wikibase.py @@ -433,8 +433,10 @@ data = self.file.latest_revision.slots['mediainfo']['*'] except NoPageError as exc: raise NoWikibaseEntityError(self) from exc - except KeyError as exc: - raise NoWikibaseEntityError(self) from exc + except KeyError: + # reuse the reserved ID for better message + self.id = 'M' + str(self.file.pageid) + raise NoWikibaseEntityError(self) from None
self._content = jsonlib.loads(data) self.id = self._content['id']
pywikibot-commits@lists.wikimedia.org