Browse Source

Replaced existing Error() usage with CKEditorError().

Piotrek Koszuliński 10 years ago
parent
commit
bf0ed27351

+ 8 - 3
packages/ckeditor5-engine/src/plugincollection.js

@@ -12,7 +12,7 @@
  * @extends Collection
  */
 
-CKEDITOR.define( [ 'collection', 'promise' ], function( Collection, Promise ) {
+CKEDITOR.define( [ 'collection', 'promise', 'ckeditorerror' ], function( Collection, Promise, CKEditorError ) {
 	class PluginCollection extends Collection {
 		/**
 		 * Creates an instance of the PluginCollection class, initializing it with a set of plugins.
@@ -77,8 +77,13 @@ CKEDITOR.define( [ 'collection', 'promise' ], function( Collection, Promise ) {
 						},
 						// Error callback.
 						function() {
-							var err = new Error( 'It was not possible to load the "' + plugin + '" plugin.' );
-							err.name = 'CKEditor Error';
+							/**
+							 * It was not possible to load the plugin.
+							 *
+							 * @error plugincollection-load
+							 * @param {String} plugin The name of the plugin that could not be loaded.
+							 */
+							var err = new CKEditorError( 'plugincollection-load: It was not possible to load the plugin.', { plugin: plugin } );
 							reject( err );
 						}
 					);

+ 4 - 3
packages/ckeditor5-engine/tests/plugincollection/plugincollection.js

@@ -7,7 +7,7 @@
 
 'use strict';
 
-var modules = bender.amd.require( 'plugincollection', 'plugin', 'editor' );
+var modules = bender.amd.require( 'plugincollection', 'plugin', 'editor', 'ckeditorerror' );
 var editor;
 var PluginA, PluginB;
 
@@ -169,6 +169,7 @@ describe( 'load', function() {
 
 	it( 'should throw an error for invalid plugins', function() {
 		var PluginCollection = modules.plugincollection;
+		var CKEditorError = modules.ckeditorerror;
 
 		var plugins = new PluginCollection( editor );
 
@@ -177,8 +178,8 @@ describe( 'load', function() {
 				throw new Error( 'Test error: this promise should not be resolved successfully' );
 			} )
 			.catch( function( err ) {
-				expect( err ).to.be.an.instanceof( Error );
-				expect( err.name ).to.equal( 'CKEditor Error' );
+				expect( err ).to.be.an.instanceof( CKEditorError );
+				expect( err.data ).to.have.property( 'plugin', 'BAD' );
 			} );
 	} );
 } );