Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/121095
Change subject: Reject ApiBasedValueParser/Formatter promise with a single parameter ...................................................................... Reject ApiBasedValueParser/Formatter promise with a single parameter As per definition in DataValuesJavaScript 0.4.1. Requires ValueView 0.5.0. Change-Id: I1825c7a88cd84dcb6e89158029ded05d409660ea --- M composer.json M lib/resources/formatters/ApiBasedValueFormatter.js M lib/resources/parsers/ApiBasedValueParser.js 3 files changed, 36 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/95/121095/3 diff --git a/composer.json b/composer.json index bc0b6fd..8d466ad 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "data-values/data-types": "~0.2.0", "data-values/serialization": "~1.0", "data-values/javascript": "~0.4.0", - "data-values/value-view": "~0.4.0", + "data-values/value-view": "~0.5.0", "wikibase/data-model": "~0.7.2", "diff/diff": "~0.9.0", "wikibase/easyrdf_lite": "~0.8.1" diff --git a/lib/resources/formatters/ApiBasedValueFormatter.js b/lib/resources/formatters/ApiBasedValueFormatter.js index 3d86860..d76630b 100644 --- a/lib/resources/formatters/ApiBasedValueFormatter.js +++ b/lib/resources/formatters/ApiBasedValueFormatter.js @@ -24,8 +24,12 @@ * @param {dataValues.DataValue} dataValue * @param {string} [dataTypeId] * @param {string} [outputType] The output's preferred MIME type - * - * @return {$.Promise} + * @return {jQuery.Promise} + * Resolved parameters: + * - {string} Formatted DataValue. + * - {dataValues.DataValues} Original DataValue object. + * Rejected parameters: + * - {string} HTML error message. */ format: function( dataValue, dataTypeId, outputType ) { var deferred = $.Deferred(); @@ -50,7 +54,17 @@ deferred.resolve( formattedValue, dataValue ); } ) .fail( function( code, details ) { - deferred.reject( code, details ); + var message = code; + + if( typeof details === 'string' ) { + message = details; + } else if( details.error && details.error.info ) { + message = details.error.info; + } else if( details.exception ) { + message = details.exception; + } + + deferred.reject( message ); } ); return deferred.promise(); diff --git a/lib/resources/parsers/ApiBasedValueParser.js b/lib/resources/parsers/ApiBasedValueParser.js index a020997..c9d03d9 100644 --- a/lib/resources/parsers/ApiBasedValueParser.js +++ b/lib/resources/parsers/ApiBasedValueParser.js @@ -28,7 +28,11 @@ * @since 0.5 * * @param {string} rawValue - * @return {$.Promise} + * @return {jQuery.Promise} + * Resolved parameters: + * - {dataValues.DataValues} + * Rejected parameters: + * - {string} HTML error message. */ parse: function( rawValue ) { var deferred = $.Deferred(); @@ -39,7 +43,19 @@ deferred.resolve( results[0] ); } ) .fail( function( code, details ) { - deferred.reject( code, details ); + var message = code; + + if( typeof details === 'string' ) { + message = details; + } else if( details['error-html'] ) { + message = details['error-html']; + } else if( details.error && details.error.info ) { + message = details.error.info; + } else if( details.exception ) { + message = details.exception; + } + + deferred.reject( message ); } ); return deferred.promise(); -- To view, visit https://gerrit.wikimedia.org/r/121095 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1825c7a88cd84dcb6e89158029ded05d409660ea Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater <henning.sna...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits