diff --git a/src/model/model.js b/src/model/model.js index 421d6a1a4..aa176fe1c 100644 --- a/src/model/model.js +++ b/src/model/model.js @@ -172,6 +172,8 @@ export default class Model { return callback( this._currentWriter ); } } catch ( err ) { + // @if CK_DEBUG // throw err; + /* istanbul ignore next */ CKEditorError.rethrowUnexpectedError( err, this ); } } @@ -224,6 +226,8 @@ export default class Model { this._runPendingChanges(); } } catch ( err ) { + // @if CK_DEBUG // throw err; + /* istanbul ignore next */ CKEditorError.rethrowUnexpectedError( err, this ); } } diff --git a/src/view/view.js b/src/view/view.js index 86b59fa3a..c449a1691 100644 --- a/src/view/view.js +++ b/src/view/view.js @@ -481,6 +481,8 @@ export default class View { return callbackResult; } catch ( err ) { + // @if CK_DEBUG // throw err; + /* istanbul ignore next */ CKEditorError.rethrowUnexpectedError( err, this ); } } diff --git a/tests/model/model.js b/tests/model/model.js index fe657c4f4..539d95dbd 100644 --- a/tests/model/model.js +++ b/tests/model/model.js @@ -324,21 +324,14 @@ describe( 'Model', () => { } ); } ); - it( 'should catch a non-ckeditor error inside the `change()` block and throw the CKEditorError error outside of it', () => { + it( 'should rethrow native errors as they are in the dubug=true mode in the model.change() block', () => { const error = new TypeError( 'foo' ); - error.stack = 'bar'; - expectToThrowCKEditorError( () => { + expect( () => { model.change( () => { throw error; } ); - }, /unexpected-error/, model, { - originalError: { - message: 'foo', - stack: 'bar', - name: 'TypeError' - } - } ); + } ).to.throw( TypeError, /foo/ ); } ); it( 'should throw the original CKEditorError error if it was thrown inside the `change()` block', () => { @@ -349,21 +342,14 @@ describe( 'Model', () => { }, /foo/, null, { foo: 1 } ); } ); - it( 'should catch a non-ckeditor error inside the `enqueueChange()` block and throw the CKEditorError error outside of it', () => { + it( 'should rethrow native errors as they are in the dubug=true mode in the enqueueChange() block', () => { const error = new TypeError( 'foo' ); - error.stack = 'bar'; - expectToThrowCKEditorError( () => { + expect( () => { model.enqueueChange( () => { throw error; } ); - }, /unexpected-error/, model, { - originalError: { - message: 'foo', - stack: 'bar', - name: 'TypeError' - } - } ); + } ).to.throw( TypeError, /foo/ ); } ); it( 'should throw the original CKEditorError error if it was thrown inside the `enqueueChange()` block', () => { diff --git a/tests/view/view/view.js b/tests/view/view/view.js index aa5a2c3f4..c280ca858 100644 --- a/tests/view/view/view.js +++ b/tests/view/view/view.js @@ -804,21 +804,14 @@ describe( 'view', () => { expect( result3 ).to.undefined; } ); - it( 'should catch native errors and wrap them into the CKEditorError errors', () => { + it( 'should rethrow native errors as they are in the dubug=true mode', () => { const error = new TypeError( 'foo' ); - error.stack = 'bar'; - expectToThrowCKEditorError( () => { + expect( () => { view.change( () => { throw error; } ); - }, /unexpected-error/, view, { - originalError: { - message: 'foo', - stack: 'bar', - name: 'TypeError' - } - } ); + } ).to.throw( TypeError, /foo/ ); } ); it( 'should rethrow custom CKEditorError errors', () => {