jenkins-bot has submitted this change and it was merged.
Change subject: Fixed wikiraw: protocol bug
......................................................................
Fixed wikiraw: protocol bug
Bug: T146010
Change-Id: I5c08e9fddbe62038eac00bd87b618efda6c05336
---
M lib/graph2.compiled.js
1 file changed, 26 insertions(+), 17 deletions(-)
Approvals:
Hashar: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/graph2.compiled.js b/lib/graph2.compiled.js
index 43700d7..b0e6c74 100644
--- a/lib/graph2.compiled.js
+++ b/lib/graph2.compiled.js
@@ -506,29 +506,37 @@
* Performs post-processing of the data requested by the graph's spec
*/
VegaWrapper.prototype.dataParser = function dataParser(error, data, opt,
callback) {
- if (error) {
- callback(error);
- return;
+ if (!error) {
+ try {
+ data = this.parseDataOrThrow(data, opt);
+ } catch (e) {
+ error = e;
+ }
}
+ if (error) data = undefined;
+ callback(error, data);
+};
+
+/**
+ * Performs post-processing of the data requested by the graph's spec, and
throw on error
+ */
+VegaWrapper.prototype.parseDataOrThrow = function parseDataOrThrow(data, opt) {
switch (opt.graphProtocol) {
case 'wikiapi:':
case 'wikiraw:':
// This was an API call - check for errors
data = JSON.parse(data);
if (data.error) {
- error = new Error('API error: ' + JSON.stringify(data.error));
- data = undefined;
- } else {
- if (data.warnings) {
- this.logger('API warnings: ' +
JSON.stringify(data.warnings));
- }
- if (opt.graphProtocol === 'wikiraw') {
- try {
- data = data.query.pages[0].revisions[0].content;
- } catch (e) {
- data = undefined;
- error = new Error('Page content not available ' +
opt.url);
- }
+ throw new Error('API error: ' + JSON.stringify(data.error));
+ }
+ if (data.warnings) {
+ this.logger('API warnings: ' + JSON.stringify(data.warnings));
+ }
+ if (opt.graphProtocol === 'wikiraw:') {
+ try {
+ data = data.query.pages[0].revisions[0].content;
+ } catch (e) {
+ throw new Error('Page content not available ' + opt.url);
}
}
break;
@@ -549,7 +557,8 @@
});
break;
}
- callback(error, data);
+
+ return data;
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/311410
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5c08e9fddbe62038eac00bd87b618efda6c05336
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Graph
Gerrit-Branch: wmf/1.28.0-wmf.18
Gerrit-Owner: Yurik <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits