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

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/965058
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/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 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to