Mpaa has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/285092

Change subject: Provide more info in case of invalid page
......................................................................

Provide more info in case of invalid page

Display the api error message, if possible, which is more informative
than current AssertionError.

Bug: T132158
Change-Id: If95a6930eac8c021a8799a7988e3d079a304e838
---
M pywikibot/data/api.py
1 file changed, 8 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/92/285092/1

diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index c3f1ddf..1a3c283 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -3118,8 +3118,14 @@
     elif "missing" in pagedict:
         page._pageid = 0    # Non-existent page
     else:
-        raise AssertionError(
-            "Page %s has neither 'pageid' nor 'missing' attribute" % 
pagedict['title'])
+        # Something is wrong.
+        if page.site.sametitle(page.title(), pagedict['title']):
+            if 'invalid' in pagedict:
+                raise Error('Page %s: %s' % (page, pagedict['invalidreason']))
+        else:
+            raise AssertionError(
+                "Page %s has neither 'pageid' nor 'missing' attribute"
+                % pagedict['title'])
     page._contentmodel = pagedict.get('contentmodel')  # can be None
     if (page._contentmodel and
             page._contentmodel == 'proofread-page' and

-- 
To view, visit https://gerrit.wikimedia.org/r/285092
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If95a6930eac8c021a8799a7988e3d079a304e838
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to