jenkins-bot submitted this change.

View Change


Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
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(-)

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']

To view, visit change 965058. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I1a130419477960856b6f976762a128d100eb43a6
Gerrit-Change-Number: 965058
Gerrit-PatchSet: 2
Gerrit-Owner: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged