Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #202 from ckeditor/i/5595
Browse files Browse the repository at this point in the history
Internal: Rethrow original error in try-catch blocks when the `debug=true` mode is on. Part of ckeditor/ckeditor5#5595.
  • Loading branch information
Reinmar authored Nov 25, 2019
2 parents 3af9e3a + 34e78de commit f581945
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
Expand Down
13 changes: 3 additions & 10 deletions tests/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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', () => {
Expand Down

0 comments on commit f581945

Please sign in to comment.