John Vandenberg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/233204
Change subject: Include requestid & servedby in APIError message
......................................................................
Include requestid & servedby in APIError message
servedby exists for 1.16+ (18d8635d)
requestid exists for 1.14+ (606d9219)
Change-Id: I13961539e713242cfa244d753c43cad14271fecc
---
M pywikibot/data/api.py
M tests/api_tests.py
2 files changed, 16 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/04/233204/1
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index d838f0c..62219ff 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -105,6 +105,14 @@
def __str__(self):
"""Return a string representation."""
+ if self.other:
+ return '[{0}] {1}: {2}'.format(
+ '; '.join(
+ '{0}:{1}'.format(key, val)
+ for key, val in self.other.items()),
+ self.code,
+ self.info)
+
return "%(code)s: %(info)s" % self.__dict__
@@ -2008,6 +2016,11 @@
if "error" not in result:
return result
+ if 'requestid' in result:
+ result['error']['requestid'] = result['requestid']
+ if 'servedby' in result:
+ result['error']['servedby'] = result['servedby']
+
if "*" in result["error"]:
# help text returned
result['error']['help'] = result['error'].pop("*")
diff --git a/tests/api_tests.py b/tests/api_tests.py
index b898c4a..6cb0c83 100644
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -40,7 +40,9 @@
"""Test raising an APIMWException."""
data = {'error': {'code': 'internal_api_error_fake',
- 'info': 'Fake error message'}}
+ 'info': 'Fake error message'},
+ 'servedby': 'unittest',
+ }
def _dummy_request(self, **kwargs):
self.assertIn('body', kwargs)
--
To view, visit https://gerrit.wikimedia.org/r/233204
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I13961539e713242cfa244d753c43cad14271fecc
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits