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

Commit

Permalink
Rethrown original error in try-catch blocks when the debug=true mod…
Browse files Browse the repository at this point in the history
…e is on.
  • Loading branch information
ma2ciek committed Nov 21, 2019
1 parent 3af9e3a commit d19cdce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ export default class Editor {
try {
this.commands.execute( ...args );
} catch ( err ) {
// @if CK_DEBUG // throw err;
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 d19cdce

Please sign in to comment.