ソースを参照

Merge pull request #202 from ckeditor/i/5595

Internal: Rethrow original error in try-catch blocks when the `debug=true` mode is on. Part of ckeditor/ckeditor5#5595.
Piotrek Koszuliński 6 年 前
コミット
c27966655b

+ 2 - 0
packages/ckeditor5-core/src/editor/editor.js

@@ -274,6 +274,8 @@ export default class Editor {
 		try {
 			this.commands.execute( ...args );
 		} catch ( err ) {
+			// @if CK_DEBUG // throw err;
+			/* istanbul ignore next */
 			CKEditorError.rethrowUnexpectedError( err, this );
 		}
 	}

+ 3 - 10
packages/ckeditor5-core/tests/editor/editor.js

@@ -391,10 +391,9 @@ describe( 'Editor', () => {
 			}, /^commandcollection-command-not-found:/, editor );
 		} );
 
-		it( 'should catch native errors and wrap them into the CKEditorError errors', () => {
+		it( 'should rethrow native errors as they are in the debug=true mode', () => {
 			const editor = new TestEditor();
 			const error = new TypeError( 'foo' );
-			error.stack = 'bar';
 
 			class SomeCommand extends Command {
 				constructor( editor ) {
@@ -408,15 +407,9 @@ describe( 'Editor', () => {
 
 			editor.commands.add( 'someCommand', new SomeCommand( editor ) );
 
-			expectToThrowCKEditorError( () => {
+			expect( () => {
 				editor.execute( 'someCommand' );
-			}, /unexpected-error/, editor, {
-				originalError: {
-					message: 'foo',
-					stack: 'bar',
-					name: 'TypeError'
-				}
-			} );
+			} ).to.throw( TypeError, /foo/ );
 		} );
 
 		it( 'should rethrow custom CKEditorError errors', () => {