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 #27 from ckeditor/t/24
Browse files Browse the repository at this point in the history
Internal: Made the missing context error an internal warning. Closes #24.
  • Loading branch information
Piotr Jasiun authored Oct 3, 2019
2 parents 5a9dc0c + 73844f3 commit 565e1aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/watchdog.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ export default class Watchdog {
* @param {ErrorEvent|PromiseRejectionEvent} evt Error event.
*/
_handleError( error, evt ) {
if ( error.is && error.is( 'CKEditorError' ) && error.context === undefined ) {
console.error( 'The error is missing its context and Watchdog cannot restart the proper editor.' );
}
// @if CK_DEBUG // if ( error.is && error.is( 'CKEditorError' ) && error.context === undefined ) {
// @if CK_DEBUG // console.warn( 'The error is missing its context and Watchdog cannot restart the proper editor.' );
// @if CK_DEBUG // }

if ( this._shouldReactToError( error ) ) {
this.crashes.push( {
Expand Down
34 changes: 0 additions & 34 deletions tests/watchdog.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,37 +466,6 @@ describe( 'Watchdog', () => {
} );
} );

it( 'Watchdog should warn if the CKEditorError missing its context', () => {
const watchdog = new Watchdog();

watchdog.setCreator( ( el, config ) => ClassicTestEditor.create( el, config ) );

// sinon.stub( window, 'onerror' ).value( undefined ); and similar do not work.
const originalErrorHandler = window.onerror;
window.onerror = undefined;

sinon.stub( console, 'error' );

return watchdog.create( element ).then( () => {
setTimeout( () => throwCKEditorError( 'foo' ) );

return new Promise( res => {
setTimeout( () => {
window.onerror = originalErrorHandler;

expect( watchdog.crashes ).to.deep.equal( [] );

sinon.assert.calledWithExactly(
console.error,
'The error is missing its context and Watchdog cannot restart the proper editor.'
);

watchdog.destroy().then( res );
} );
} );
} );
} );

it( 'Watchdog should omit error if the CKEditorError context is equal to null', () => {
const watchdog = new Watchdog();

Expand All @@ -506,8 +475,6 @@ describe( 'Watchdog', () => {
const originalErrorHandler = window.onerror;
window.onerror = undefined;

sinon.stub( console, 'error' );

return watchdog.create( element ).then( () => {
setTimeout( () => throwCKEditorError( 'foo', null ) );

Expand All @@ -516,7 +483,6 @@ describe( 'Watchdog', () => {
window.onerror = originalErrorHandler;

expect( watchdog.crashes ).to.deep.equal( [] );
sinon.assert.notCalled( console.error );

watchdog.destroy().then( res );
} );
Expand Down

0 comments on commit 565e1aa

Please sign in to comment.