return xhr;
}
} )
+ .then( null, function ( code, data, result, jqXHR ) {
+ if ( code !== 'http' ) {
+ // Not really an error, work around mw.Api thinking it is.
+ return $.Deferred()
+ .resolve( result, jqXHR )
+ .promise();
+ }
+ return this;
+ } )
.fail( function ( code, data ) {
var details = 'HTTP error: ' + data.exception;
$result.empty()
.done( function ( result, textStatus, jqXHR ) {
if ( result === undefined || result === null || result === '' ) {
apiDeferred.reject( 'ok-but-empty',
- 'OK response but empty result (check HTTP headers?)'
+ 'OK response but empty result (check HTTP headers?)',
+ result,
+ jqXHR
);
} else if ( result.error ) {
var code = result.error.code === undefined ? 'unknown' : result.error.code;
- apiDeferred.reject( code, result );
+ apiDeferred.reject( code, result, result, jqXHR );
} else {
apiDeferred.resolve( result, jqXHR );
}