[MediaWiki-commits] [Gerrit] mediawiki...Graph[master]: Fixed wikiraw: protocol bug
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: Yurik: 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/311372 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5c08e9fddbe62038eac00bd87b618efda6c05336 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Graph Gerrit-Branch: master Gerrit-Owner: YurikGerrit-Reviewer: JGirault Gerrit-Reviewer: Yurik Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki...Graph[master]: Fixed wikiraw: protocol bug
Yurik has uploaded a new change for review. https://gerrit.wikimedia.org/r/311372 Change subject: Fixed wikiraw: protocol bug .. Fixed wikiraw: protocol bug Change-Id: I5c08e9fddbe62038eac00bd87b618efda6c05336 --- M lib/graph2.compiled.js 1 file changed, 26 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Graph refs/changes/72/311372/1 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/311372 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5c08e9fddbe62038eac00bd87b618efda6c05336 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Graph Gerrit-Branch: master Gerrit-Owner: Yurik___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits