- // Errors in this format are produced by TitleBlacklist and AbuseFilter. Perhaps other
- // extensions will follow this format in the future.
- if ( error.message ) {
- return this.upload.getApi()
- .then( function ( api ) {
- // 'amenableparser' will expand templates and parser functions server-side.
- // We still do the rest of wikitext parsing here (through jqueryMsg).
- return api.loadMessagesIfMissing( [ error.message.key ], { amenableparser: true } )
- .then( function () {
- if ( !mw.message( error.message.key ).exists() ) {
- return $.Deferred().reject();
- }
- return new OO.ui.Error(
- $( '<p>' ).msg( error.message.key, error.message.params || [] ),
- { recoverable: false }
- );
- } );
- } )
- .then( null, function () {
- // We failed when loading the error message, or it doesn't actually exist, fall back
- return $.Deferred().resolve( new OO.ui.Error(
- $( '<p>' ).msg( 'api-error-unknownerror', JSON.stringify( stateDetails ) ),
- { recoverable: false }
- ) );
- } );
- }
-
- if ( error.code === 'protectedpage' ) {
- message = mw.message( 'protectedpagetext' );
- } else {
- message = mw.message( 'api-error-' + error.code );
- if ( !message.exists() ) {
- message = mw.message( 'api-error-unknownerror', JSON.stringify( stateDetails ) );
- }
- }