[MediaWiki-commits] [Gerrit] Handle specific parse errors returned by the API - change (mediawiki...Wikibase)
Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/121087 Change subject: Handle specific parse errors returned by the API .. Handle specific parse errors returned by the API Evaluates the response structure introduced in change I5b3e27cbbfd01ed1b724ec480a5470e741da7f4c. Change-Id: I104ef7b09ceabe0b09d4c7118f806adb91fcf75f --- M lib/resources/parsers/wikibase.parsers.api.js 1 file changed, 20 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/87/121087/1 diff --git a/lib/resources/parsers/wikibase.parsers.api.js b/lib/resources/parsers/wikibase.parsers.api.js index cce87d7..44307ec 100644 --- a/lib/resources/parsers/wikibase.parsers.api.js +++ b/lib/resources/parsers/wikibase.parsers.api.js @@ -26,7 +26,13 @@ * @param {string} parser * @param {string[]} values * @param {Object} options -* @return {$.Promise} +* @return {jQuery.Promise} +* Resolved parameters: +* - {dataValues.DataValues[]} +* Rejected parameters: +* - {string} Error code. +* - {string|Object} Error message, original response containing "error" attribute or +* status object (see mediaWiki.Api.ajax). */ wb.parsers.api.parseValues = function( parser, values, options ) { var deferred = $.Deferred(); @@ -56,11 +62,19 @@ var dataValues = []; - for ( var i in response.results ) { - try{ - dataValues.push( unserializeResult( response.results[i] ) ); - } catch( e ) { - deferred.reject( e.name, e.message ); + for( var i in response.results ) { + var result = response.results[i]; + + if( result.error ) { + deferred.reject( result.error, result ); + break; + } + + try { + dataValues.push( unserializeResult( result ) ); + } catch( error ) { + deferred.reject( error.name, error.message ); + break; } } -- To view, visit https://gerrit.wikimedia.org/r/121087 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I104ef7b09ceabe0b09d4c7118f806adb91fcf75f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Handle specific parse errors returned by the API - change (mediawiki...Wikibase)
jenkins-bot has submitted this change and it was merged. Change subject: Handle specific parse errors returned by the API .. Handle specific parse errors returned by the API Evaluates the response structure introduced in change I5b3e27cbbfd01ed1b724ec480a5470e741da7f4c. (bug 62822) Change-Id: I104ef7b09ceabe0b09d4c7118f806adb91fcf75f --- M lib/resources/parsers/wikibase.parsers.api.js 1 file changed, 20 insertions(+), 6 deletions(-) Approvals: WikidataJenkins: Verified Adrian Lang: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/resources/parsers/wikibase.parsers.api.js b/lib/resources/parsers/wikibase.parsers.api.js index cce87d7..44307ec 100644 --- a/lib/resources/parsers/wikibase.parsers.api.js +++ b/lib/resources/parsers/wikibase.parsers.api.js @@ -26,7 +26,13 @@ * @param {string} parser * @param {string[]} values * @param {Object} options -* @return {$.Promise} +* @return {jQuery.Promise} +* Resolved parameters: +* - {dataValues.DataValues[]} +* Rejected parameters: +* - {string} Error code. +* - {string|Object} Error message, original response containing "error" attribute or +* status object (see mediaWiki.Api.ajax). */ wb.parsers.api.parseValues = function( parser, values, options ) { var deferred = $.Deferred(); @@ -56,11 +62,19 @@ var dataValues = []; - for ( var i in response.results ) { - try{ - dataValues.push( unserializeResult( response.results[i] ) ); - } catch( e ) { - deferred.reject( e.name, e.message ); + for( var i in response.results ) { + var result = response.results[i]; + + if( result.error ) { + deferred.reject( result.error, result ); + break; + } + + try { + dataValues.push( unserializeResult( result ) ); + } catch( error ) { + deferred.reject( error.name, error.message ); + break; } } -- To view, visit https://gerrit.wikimedia.org/r/121087 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I104ef7b09ceabe0b09d4c7118f806adb91fcf75f Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater Gerrit-Reviewer: Addshore Gerrit-Reviewer: Adrian Lang Gerrit-Reviewer: Thiemo Mättig (WMDE) Gerrit-Reviewer: Tobias Gritschacher Gerrit-Reviewer: WikidataJenkins Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits