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 81551f8 commit cd61e9b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/componentfactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ export default class ComponentFactory {
* @param {String} name The name of the component.
*/
throw new CKEditorError(
'componentfactory-item-exists: The item already exists in the component factory.', { name }
'componentfactory-item-exists: The item already exists in the component factory.',
this,
{ name }
);
}

Expand Down Expand Up @@ -113,7 +115,9 @@ export default class ComponentFactory {
* @param {String} name The name of the missing component.
*/
throw new CKEditorError(
'componentfactory-item-missing: The required component is not registered in the factory.', { name }
'componentfactory-item-missing: The required component is not registered in the factory.',
this,
{ name }
);
}

Expand Down
15 changes: 12 additions & 3 deletions src/panel/balloon/contextualballoon.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ export default class ContextualBalloon extends Plugin {
*
* @error contextualballoon-add-view-exist
*/
throw new CKEditorError( 'contextualballoon-add-view-exist: Cannot add configuration of the same view twice.' );
throw new CKEditorError(
'contextualballoon-add-view-exist: Cannot add configuration of the same view twice.',
[ this, data ]
);
}

const stackId = data.stackId || 'main';
Expand Down Expand Up @@ -248,7 +251,10 @@ export default class ContextualBalloon extends Plugin {
*
* @error contextualballoon-remove-view-not-exist
*/
throw new CKEditorError( 'contextualballoon-remove-view-not-exist: Cannot remove the configuration of a non-existent view.' );
throw new CKEditorError(
'contextualballoon-remove-view-not-exist: Cannot remove the configuration of a non-existent view.',
[ this, view ]
);
}

const stack = this._viewToStack.get( view );
Expand Down Expand Up @@ -313,7 +319,10 @@ export default class ContextualBalloon extends Plugin {
*
* @error contextualballoon-showstack-stack-not-exist
*/
throw new CKEditorError( 'contextualballoon-showstack-stack-not-exist: Cannot show a stack that does not exist.' );
throw new CKEditorError(
'contextualballoon-showstack-stack-not-exist: Cannot show a stack that does not exist.',
this
);
}

if ( this._visibleStack === stack ) {
Expand Down
12 changes: 9 additions & 3 deletions src/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ export default class Template {
*
* @error ui-template-revert-not-applied
*/
throw new CKEditorError( 'ui-template-revert-not-applied: Attempting to revert a template which has not been applied yet.' );
throw new CKEditorError(
'ui-template-revert-not-applied: Attempting to revert a template which has not been applied yet.',
[ this, node ]
);
}

this._revertTemplateFromNode( node, this._revertData );
Expand Down Expand Up @@ -409,7 +412,8 @@ export default class Template {
* @error ui-template-wrong-syntax
*/
throw new CKEditorError(
'ui-template-wrong-syntax: Node definition must have either "tag" or "text" when rendering a new Node.'
'ui-template-wrong-syntax: Node definition must have either "tag" or "text" when rendering a new Node.',
this
);
}

Expand Down Expand Up @@ -1356,6 +1360,7 @@ function extendObjectValueArray( obj, ext ) {
//
// @param {module:ui/template~Template} def A template instance to be extended.
// @param {module:ui/template~TemplateDefinition} def A definition which is to extend the template instance.
// @param {Object} Error context.
function extendTemplate( template, def ) {
if ( def.attributes ) {
if ( !template.attributes ) {
Expand Down Expand Up @@ -1385,7 +1390,8 @@ function extendTemplate( template, def ) {
* @error ui-template-extend-children-mismatch
*/
throw new CKEditorError(
'ui-template-extend-children-mismatch: The number of children in extended definition does not match.'
'ui-template-extend-children-mismatch: The number of children in extended definition does not match.',
template
);
}

Expand Down
5 changes: 4 additions & 1 deletion src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,10 @@ export default class View {
*
* @error ui-view-render-rendered
*/
throw new CKEditorError( 'ui-view-render-already-rendered: This View has already been rendered.' );
throw new CKEditorError(
'ui-view-render-already-rendered: This View has already been rendered.',
this
);
}

// Render #element of the view.
Expand Down
5 changes: 4 additions & 1 deletion src/viewcollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ export default class ViewCollection extends Collection {
*
* @error ui-viewcollection-delegate-wrong-events
*/
throw new CKEditorError( 'ui-viewcollection-delegate-wrong-events: All event names must be strings.' );
throw new CKEditorError(
'ui-viewcollection-delegate-wrong-events: All event names must be strings.',
this
);
}

return {
Expand Down

0 comments on commit cd61e9b

Please sign in to comment.