Browse Source

Fixed error contexts.

Maciej Bukowski 6 years ago
parent
commit
fe5d0378a2

+ 6 - 2
packages/ckeditor5-ui/src/componentfactory.js

@@ -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 }
 			);
 		}
 
@@ -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 }
 			);
 		}
 

+ 12 - 3
packages/ckeditor5-ui/src/panel/balloon/contextualballoon.js

@@ -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';
@@ -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 );
@@ -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 ) {

+ 9 - 3
packages/ckeditor5-ui/src/template.js

@@ -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 );
@@ -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
 			);
 		}
 
@@ -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 ) {
@@ -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
 			);
 		}
 

+ 4 - 1
packages/ckeditor5-ui/src/view.js

@@ -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.

+ 4 - 1
packages/ckeditor5-ui/src/viewcollection.js

@@ -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 {