Ver código fonte

Improved ids of the context errors.

Oskar Wróbel 6 anos atrás
pai
commit
8660e6dcca

+ 10 - 4
packages/ckeditor5-core/src/context.js

@@ -72,8 +72,6 @@ export default class Context {
 	 * Adds a reference to the editor to which context is injected.
 	 *
 	 * @param {module:core/editor/editor~Editor} editor
-	 * @param {Boolean} isHost Flag defines if context was created by this editor. It is used to decide if the context
-	 * should be destroyed along with the editor instance.
 	 */
 	addEditor( editor ) {
 		this._editors.add( editor );
@@ -99,11 +97,19 @@ export default class Context {
 
 		for ( const Plugin of plugins ) {
 			if ( typeof Plugin != 'function' ) {
-				throw new CKEditorError( 'context-initplugins: Only constructor is allowed as a Context plugin.', null, { Plugin } );
+				throw new CKEditorError(
+					'context-initplugins-constructor-only: Only constructor is allowed as a Context plugin.',
+					null,
+					{ Plugin }
+				);
 			}
 
 			if ( Plugin.isContextPlugin !== true ) {
-				throw new CKEditorError( 'context-initplugins: Only plugins marked as a ContextPlugin are allowed.', null, { Plugin } );
+				throw new CKEditorError(
+					'context-initplugins-invalid-plugin: Only plugin marked as a ContextPlugin is allowed.',
+					null,
+					{ Plugin }
+				);
 			}
 		}
 

+ 8 - 5
packages/ckeditor5-core/tests/context.js

@@ -80,7 +80,7 @@ describe( 'Context', () => {
 	} );
 
 	describe( 'plugins', () => {
-		it( 'should throw when plugin added to the context is not marked as a ContextPlugin #1', async () => {
+		it( 'should throw when plugin added to the context is not marked as a ContextPlugin (Plugin)', async () => {
 			class EditorPlugin extends Plugin {}
 
 			let caughtError;
@@ -92,10 +92,11 @@ describe( 'Context', () => {
 			}
 
 			expect( caughtError ).to.instanceof( CKEditorError );
-			expect( caughtError.message ).match( /^context-initplugins: Only plugins marked as a ContextPlugin are allowed./ );
+			expect( caughtError.message )
+				.match( /^context-initplugins-invalid-plugin: Only plugin marked as a ContextPlugin is allowed./ );
 		} );
 
-		it( 'should throw when plugin added to the context is not marked as a ContextPlugin #2', async () => {
+		it( 'should throw when plugin added to the context is not marked as a ContextPlugin (Function)', async () => {
 			function EditorPlugin() {}
 
 			let caughtError;
@@ -107,7 +108,8 @@ describe( 'Context', () => {
 			}
 
 			expect( caughtError ).to.instanceof( CKEditorError );
-			expect( caughtError.message ).match( /^context-initplugins: Only plugins marked as a ContextPlugin are allowed./ );
+			expect( caughtError.message )
+				.match( /^context-initplugins-invalid-plugin: Only plugin marked as a ContextPlugin is allowed./ );
 		} );
 
 		it( 'should throw when plugin is added to the context by name', async () => {
@@ -120,7 +122,8 @@ describe( 'Context', () => {
 			}
 
 			expect( caughtError ).to.instanceof( CKEditorError );
-			expect( caughtError.message ).match( /^context-initplugins: Only constructor is allowed as a Context plugin./ );
+			expect( caughtError.message )
+				.match( /^context-initplugins-constructor-only: Only constructor is allowed as a Context plugin./ );
 		} );
 
 		it( 'should not throw when plugin as a function, marked as a ContextPlugin is added to the context', async () => {