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

Commit

Permalink
Fixed error contexts.
Browse files Browse the repository at this point in the history
  • Loading branch information
ma2ciek committed Jul 1, 2019
1 parent de63e08 commit e8d7d1b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/mentioncommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ export default class MentionCommand extends Command {
*
* @error mentioncommand-incorrect-marker
*/
throw new CKEditorError( 'mentioncommand-incorrect-marker: The marker must be a single character.' );
throw new CKEditorError(
'mentioncommand-incorrect-marker: The marker must be a single character.',
this
);
}

if ( mentionID.charAt( 0 ) != options.marker ) {
Expand Down Expand Up @@ -127,7 +130,10 @@ export default class MentionCommand extends Command {
*
* @error mentioncommand-incorrect-id
*/
throw new CKEditorError( 'mentioncommand-incorrect-id: The item id must start with the marker character.' );
throw new CKEditorError(
'mentioncommand-incorrect-id: The item id must start with the marker character.',
this
);
}

model.change( writer => {
Expand Down
5 changes: 4 additions & 1 deletion src/mentionui.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ export default class MentionUI extends Plugin {
*
* @error mentionconfig-incorrect-marker
*/
throw new CKEditorError( 'mentionconfig-incorrect-marker: The marker must be provided and it must be a single character.' );
throw new CKEditorError(
'mentionconfig-incorrect-marker: The marker must be provided and it must be a single character.',
null
);
}

const minimumCharacters = mentionDescription.minimumCharacters || 0;
Expand Down
6 changes: 3 additions & 3 deletions tests/mentionui.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ describe( 'MentionUI', () => {
describe( 'init()', () => {
it( 'should throw if marker was not provided for feed', () => {
return createClassicTestEditor( { feeds: [ { feed: [ 'a' ] } ] } ).catch( error => {
assertCKEditorError( error, /mentionconfig-incorrect-marker/, editor );
assertCKEditorError( error, /mentionconfig-incorrect-marker/, null );
} );
} );

it( 'should throw if marker is empty string', () => {
return createClassicTestEditor( { feeds: [ { marker: '', feed: [ 'a' ] } ] } ).catch( error => {
assertCKEditorError( error, /mentionconfig-incorrect-marker/, editor );
assertCKEditorError( error, /mentionconfig-incorrect-marker/, null );
} );
} );

it( 'should throw if marker is longer then 1 character', () => {
return createClassicTestEditor( { feeds: [ { marker: '$$', feed: [ 'a' ] } ] } ).catch( error => {
assertCKEditorError( error, /mentionconfig-incorrect-marker/, editor );
assertCKEditorError( error, /mentionconfig-incorrect-marker/, null );
} );
} );
} );
Expand Down

0 comments on commit e8d7d1b

Please sign in to comment.