Browse Source

Changed: names of errors thrown by operations.

Szymon Cofalik 9 years ago
parent
commit
f0b2c31454

+ 2 - 2
packages/ckeditor5-engine/src/model/operation/attributeoperation.js

@@ -124,12 +124,12 @@ export default class AttributeOperation extends Operation {
 				/**
 				 * The attribute with given key already exists for the given node.
 				 *
-				 * @error operation-attribute-attr-exists
+				 * @error attribute-operation-attribute-exists
 				 * @param {engine.model.Node} node
 				 * @param {String} key
 				 */
 				throw new CKEditorError(
-					'operation-attribute-attr-exists: The attribute with given key already exists.',
+					'attribute-operation-attribute-exists: The attribute with given key already exists.',
 					{ node: item, key: this.key }
 				);
 			}

+ 8 - 8
packages/ckeditor5-engine/src/model/operation/moveoperation.js

@@ -123,28 +123,28 @@ export default class MoveOperation extends Operation {
 			/**
 			 * Source position or target position is invalid.
 			 *
-			 * @error operation-move-position-invalid
+			 * @error move-operation-position-invalid
 			 */
 			throw new CKEditorError(
-				'operation-move-position-invalid: Source position or target position is invalid.'
+				'move-operation-position-invalid: Source position or target position is invalid.'
 			);
 		} else if ( sourceOffset + this.howMany > sourceElement.getMaxOffset() ) {
 			/**
 			 * The nodes which should be moved do not exist.
 			 *
-			 * @error operation-move-nodes-do-not-exist
+			 * @error move-operation-nodes-do-not-exist
 			 */
 			throw new CKEditorError(
-				'operation-move-nodes-do-not-exist: The nodes which should be moved do not exist.'
+				'move-operation-nodes-do-not-exist: The nodes which should be moved do not exist.'
 			);
 		} else if ( sourceElement === targetElement && sourceOffset < targetOffset && targetOffset < sourceOffset + this.howMany ) {
 			/**
 			 * Trying to move a range of nodes into the middle of that range.
 			 *
-			 * @error operation-move-range-into-itself
+			 * @error move-operation-range-into-itself
 			 */
 			throw new CKEditorError(
-				'operation-move-range-into-itself: Trying to move a range of nodes to the inside of that range.'
+				'move-operation-range-into-itself: Trying to move a range of nodes to the inside of that range.'
 			);
 		} else if ( this.sourcePosition.root == this.targetPosition.root ) {
 			if ( compareArrays( this.sourcePosition.getParentPath(), this.targetPosition.getParentPath() ) == 'prefix' ) {
@@ -154,10 +154,10 @@ export default class MoveOperation extends Operation {
 					/**
 					 * Trying to move a range of nodes into one of nodes from that range.
 					 *
-					 * @error operation-move-node-into-itself
+					 * @error move-operation-node-into-itself
 					 */
 					throw new CKEditorError(
-						'operation-move-node-into-itself: Trying to move a range of nodes into one of nodes from that range.'
+						'move-operation-node-into-itself: Trying to move a range of nodes into one of nodes from that range.'
 					);
 				}
 			}

+ 5 - 5
packages/ckeditor5-engine/src/model/operation/rootattributeoperation.js

@@ -93,13 +93,13 @@ export default class RootAttributeOperation extends Operation {
 			/**
 			 * The attribute which should be removed does not exists for the given node.
 			 *
-			 * @error operation-rootattribute-no-attr-to-remove
+			 * @error rootattribute-operation-wrong-old-value
 			 * @param {engine.model.RootElement} root
 			 * @param {String} key
 			 * @param {*} value
 			 */
 			throw new CKEditorError(
-				'operation-rootattribute-no-attr-to-remove: The attribute which should be removed does not exists for given node.',
+				'rootattribute-operation-wrong-old-value: Changed node has different attribute value than operation\'s old attribute value.',
 				{ root: this.root, key: this.key }
 			);
 		}
@@ -108,12 +108,12 @@ export default class RootAttributeOperation extends Operation {
 			/**
 			 * The attribute with given key already exists for the given node.
 			 *
-			 * @error operation-rootattribute-attr-exists
+			 * @error rootattribute-operation-attribute-exists
 			 * @param {engine.model.RootElement} root
 			 * @param {String} key
 			 */
 			throw new CKEditorError(
-				'operation-rootattribute-attr-exists: The attribute with given key already exists.',
+				'rootattribute-operation-attribute-exists: The attribute with given key already exists.',
 				{ root: this.root, key: this.key }
 			);
 		}
@@ -150,7 +150,7 @@ export default class RootAttributeOperation extends Operation {
 			 * @param {String} rootName
 			 */
 			throw new CKEditorError(
-				'rootattributeoperation-fromjson-no-root: Cannot create RootAttributeOperation. Root with specified name does not exist.',
+				'rootattribute-operation-fromjson-no-root: Cannot create RootAttributeOperation. Root with specified name does not exist.',
 				{ rootName: json }
 			);
 		}

+ 1 - 1
packages/ckeditor5-engine/tests/model/operation/attributeoperation.js

@@ -312,7 +312,7 @@ describe( 'AttributeOperation', () => {
 					doc.version
 				)
 			) );
-		} ).to.throw( CKEditorError, /operation-attribute-attr-exists/ );
+		} ).to.throw( CKEditorError, /attribute-operation-attribute-exists/ );
 	} );
 
 	it( 'should create an AttributeOperation with the same parameters when cloned', () => {

+ 4 - 4
packages/ckeditor5-engine/tests/model/operation/moveoperation.js

@@ -161,7 +161,7 @@ describe( 'MoveOperation', () => {
 			doc.version
 		);
 
-		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /operation-move-nodes-do-not-exist/ );
+		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /move-operation-nodes-do-not-exist/ );
 	} );
 
 	it( 'should throw an error if target or source parent-element specified by position does not exist', () => {
@@ -178,7 +178,7 @@ describe( 'MoveOperation', () => {
 
 		root.removeChildren( 1 );
 
-		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /operation-move-position-invalid/ );
+		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /move-operation-position-invalid/ );
 	} );
 
 	it( 'should throw an error if operation tries to move a range between the beginning and the end of that range', () => {
@@ -191,7 +191,7 @@ describe( 'MoveOperation', () => {
 			doc.version
 		);
 
-		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /operation-move-range-into-itself/ );
+		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /move-operation-range-into-itself/ );
 	} );
 
 	it( 'should throw an error if operation tries to move a range into a sub-tree of a node that is in that range', () => {
@@ -205,7 +205,7 @@ describe( 'MoveOperation', () => {
 			doc.version
 		);
 
-		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /operation-move-node-into-itself/ );
+		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /move-operation-node-into-itself/ );
 	} );
 
 	it( 'should not throw an error if operation move a range into a sibling', () => {

+ 3 - 3
packages/ckeditor5-engine/tests/model/operation/rootattributeoperation.js

@@ -186,7 +186,7 @@ describe( 'RootAttributeOperation', () => {
 					doc.version
 				)
 			) );
-		} ).to.throw( CKEditorError, /operation-rootattribute-no-attr-to-remove/ );
+		} ).to.throw( CKEditorError, /rootattribute-operation-wrong-old-value/ );
 	} );
 
 	it( 'should throw an error when one try to insert and the attribute already exists', () => {
@@ -202,7 +202,7 @@ describe( 'RootAttributeOperation', () => {
 					doc.version
 				)
 			) );
-		} ).to.throw( CKEditorError, /operation-rootattribute-attr-exists/ );
+		} ).to.throw( CKEditorError, /rootattribute-operation-attribute-exists/ );
 	} );
 
 	it( 'should create a RootAttributeOperation with the same parameters when cloned', () => {
@@ -271,7 +271,7 @@ describe( 'RootAttributeOperation', () => {
 
 			expect( () => {
 				RootAttributeOperation.fromJSON( serialized, doc );
-			} ).to.throw( CKEditorError, /rootattributeoperation-fromjson-no-root/ );
+			} ).to.throw( CKEditorError, /rootattribute-operation-fromjson-no-roo/ );
 		} );
 	} );
 } );