Skip to content

Commit

Permalink
Simplified error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tade0 committed Jun 2, 2015
1 parent 0794c36 commit a076149
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
4 changes: 2 additions & 2 deletions plugins/filetools/lang/en.js
Expand Up @@ -9,5 +9,5 @@ CKEDITOR.plugins.setLang( 'filetools', 'en', {
httpError403: 'HTTP error occurred during file uploading (403: Forbidden).',
httpError: 'HTTP error occurred during file uploading (error status: %1).',
noUrlError: 'Upload URL is not defined.',
responseError: 'Incorrect server response format: %1'
} );
responseError: 'Incorrect server response.'
} );
9 changes: 3 additions & 6 deletions plugins/filetools/plugin.js
Expand Up @@ -178,12 +178,9 @@
}
} catch ( err ) {
// Response parsing error.
var responseError = fileLoader.lang.filetools.responseError;
if ( xhr.getResponseHeader( 'content-type' ).search( 'text/plain' ) !== -1 ) {
data.message = responseError.replace( '%1', xhr.responseText );
} else {
data.message = responseError.replace( ': %1', '.' );
}
data.message = fileLoader.lang.filetools.responseError;
window.console && window.console.log( xhr.responseText );

evt.cancel();
}
}, null, null, 999 );
Expand Down
22 changes: 8 additions & 14 deletions tests/plugins/filetools/filetools.js
Expand Up @@ -173,35 +173,29 @@
},

'test fileUploadResponse event': function() {
var log = window.console && sinon.spy( window.console, 'log' );

var message = 'Not a JSON';
var contentType;
var error = 'Error.';

//Mock
// Mock.
var data = {
fileLoader: {
xhr: {
getResponseHeader: function() {
return contentType;
},
responseText: message
},

lang: {
filetools: {
responseError: 'Error: %1'
responseError: error
}
}
}
};

contentType = 'text/plain';

this.editor.fire( 'fileUploadResponse', data );
assert.areEqual( data.message, 'Error: ' + message );

contentType = 'text/html';

this.editor.fire( 'fileUploadResponse', data );
assert.areEqual( data.message, 'Error.' );
assert.areEqual( data.message, error );
assert.isTrue( log ? log.calledWith( message ) : true );
}
} );
} )();

0 comments on commit a076149

Please sign in to comment.