Subramanya Sastry has uploaded a new change for review.
https://gerrit.wikimedia.org/r/235402
Change subject: Improved API error reporting for ease of debugging
......................................................................
Improved API error reporting for ease of debugging
* We were not properly reporting mediawiki API errors in many
places and logging generic opaque error messages which are
not useful in terms of debugging the errors.
Change-Id: Ide384c75ba7f253a6b1e08a4451b8468c515b3e8
---
M lib/mediawiki.ApiRequest.js
1 file changed, 27 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/02/235402/1
diff --git a/lib/mediawiki.ApiRequest.js b/lib/mediawiki.ApiRequest.js
index ddeb0d7..6015718 100644
--- a/lib/mediawiki.ApiRequest.js
+++ b/lib/mediawiki.ApiRequest.js
@@ -435,7 +435,11 @@
logAPIWarnings(this, data);
if (!error && !data.query) {
- error = new Error("API response is missing query for: " +
this.title);
+ if (data.error) {
+ error = new Error(JSON.stringify(data.error));
+ } else {
+ error = new Error("API response is missing query for: "
+ this.title);
+ }
}
if (error) {
@@ -574,8 +578,13 @@
logAPIWarnings(this, data);
if (!error && !(data && data.expandtemplates)) {
- error = new Error(util.format('Expanding template for %s: %s',
- this.title, this.text));
+ var debugInfo = util.format('Expanding template for %s: %s',
+ this.title, this.text);
+ if (data.error) {
+ error = new Error(debugInfo + '; ' +
JSON.stringify(data.error));
+ } else {
+ error = new Error(debugInfo);
+ }
}
if (error) {
@@ -655,8 +664,13 @@
logAPIWarnings(this, data);
if (!error && !(data && data.parse)) {
- error = new Error(util.format('Parsing extension for %s: %s',
- this.title, this.text));
+ var debugInfo = util.format('Parsing extensoin for %s: %s',
+ this.title, this.text);
+ if (data.error) {
+ error = new Error(debugInfo + '; ' +
JSON.stringify(data.error));
+ } else {
+ error = new Error(debugInfo);
+ }
}
if (error) {
@@ -717,7 +731,11 @@
BatchRequest.prototype._handleJSON = function(error, data) {
if (!error && !(data && data['parsoid-batch'] &&
Array.isArray(data['parsoid-batch']))) {
- error = new Error('Invalid result when expanding template
batch');
+ if (data.error) {
+ error = new Error(JSON.stringify(data.error));
+ } else {
+ error = new Error('Invalid result when expanding
template batch');
+ }
}
if (error) {
@@ -901,7 +919,7 @@
if (data.error.code === 'readapidenied') {
error = new AccessDeniedError();
} else {
- error = new Error('Something happened on the
API side. Message: ' +
+ error = new Error('API Error: ' +
data.error.code + ': ' +
data.error.info);
}
} else {
@@ -1021,7 +1039,8 @@
if (data.error.code === 'readapidenied') {
error = new AccessDeniedError();
} else {
- error = new Error('Something happened on the API side.
Message: ' + data.error.code + ': ' + data.error.info);
+ error = new Error('API Error: ' +
+ data.error.code + ': ' + data.error.info);
}
this._processListeners(error, {});
} else {
--
To view, visit https://gerrit.wikimedia.org/r/235402
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide384c75ba7f253a6b1e08a4451b8468c515b3e8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits