瀏覽代碼

Added context to thrown `CKEditorError`s.

Maciej Bukowski 6 年之前
父節點
當前提交
d911f06892

+ 1 - 1
packages/ckeditor5-ckfinder/src/ckfindercommand.js

@@ -54,7 +54,7 @@ export default class CKFinderCommand extends Command {
 		const openerMethod = this.editor.config.get( 'ckfinder.openerMethod' ) || 'modal';
 
 		if ( openerMethod != 'popup' && openerMethod != 'modal' ) {
-			throw new CKEditorError( 'ckfinder-unknown-openerMethod: The openerMethod config option must by "popup" or "modal".' );
+			throw new CKEditorError( 'ckfinder-unknown-openerMethod: The openerMethod config option must by "popup" or "modal".', editor );
 		}
 
 		const options = this.editor.config.get( 'ckfinder.options' ) || {};

+ 3 - 3
packages/ckeditor5-ckfinder/tests/ckfindercommand.js

@@ -8,7 +8,6 @@
 import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
 import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
-import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 import ImageEditing from '@ckeditor/ckeditor5-image/src/image/imageediting';
 import ImageUploadEditing from '@ckeditor/ckeditor5-image/src/imageupload/imageuploadediting';
@@ -17,6 +16,7 @@ import Notification from '@ckeditor/ckeditor5-ui/src/notification/notification';
 import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard';
 
 import CKFinderCommand from '../src/ckfindercommand';
+import { expectToThrowCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 describe( 'CKFinderCommand', () => {
 	let editor, command, model;
@@ -152,9 +152,9 @@ describe( 'CKFinderCommand', () => {
 		it( 'should throw if unsupported CKFinder opener method was set', () => {
 			editor.config.set( 'ckfinder.openerMethod', 'foobar' );
 
-			expect( () => {
+			expectToThrowCKEditorError( () => {
 				command.execute();
-			} ).to.throw( CKEditorError, /ckfinder-unknown-openerMethod/ );
+			}, /ckfinder-unknown-openerMethod/, editor );
 		} );
 
 		it( 'should insert single chosen image', () => {