瀏覽代碼

Unified error codes.

Oskar Wrobel 9 年之前
父節點
當前提交
bd55233ff4

+ 2 - 2
packages/ckeditor5-engine/src/model/selection.js

@@ -213,7 +213,7 @@ export default class Selection {
 	 */
 	addRange( range, isBackward ) {
 		if ( !( range instanceof Range ) ) {
-			throw new CKEditorError( 'model-selection-invalid-range: Invalid Range.' );
+			throw new CKEditorError( 'selection-invalid-range: Invalid Range.' );
 		}
 
 		this._pushRange( range );
@@ -296,7 +296,7 @@ export default class Selection {
 
 		for ( let range of newRanges ) {
 			if ( !( range instanceof Range ) ) {
-				throw new CKEditorError( 'model-selection-invalid-range: Invalid Range.' );
+				throw new CKEditorError( 'selection-invalid-range: Invalid Range.' );
 			}
 
 			this._pushRange( range );

+ 6 - 6
packages/ckeditor5-engine/src/view/selection.js

@@ -122,7 +122,7 @@ export default class Selection {
 	 * The flag is used to set {@link engine.view.Selection#anchor anchor} and
 	 * {@link engine.view.Selection#focus focus} properties.
 	 *
-	 * Throws {@link utils.CKEditorError CKEditorError} `view-selection-range-intersects` if added range intersects
+	 * Throws {@link utils.CKEditorError CKEditorError} `selection-range-intersects` if added range intersects
 	 * with ranges already stored in Selection instance.
 	 *
 	 * @fires engine.view.Selection#change
@@ -130,7 +130,7 @@ export default class Selection {
 	 */
 	addRange( range, isBackward ) {
 		if ( !( range instanceof Range ) ) {
-			throw new CKEditorError( 'view-selection-invalid-range: Invalid Range.' );
+			throw new CKEditorError( 'selection-invalid-range: Invalid Range.' );
 		}
 
 		this._pushRange( range );
@@ -264,7 +264,7 @@ export default class Selection {
 
 		for ( let range of newRanges ) {
 			if ( !( range instanceof Range ) ) {
-				throw new CKEditorError( 'view-selection-invalid-range: Invalid Range.' );
+				throw new CKEditorError( 'selection-invalid-range: Invalid Range.' );
 			}
 
 			this._pushRange( range );
@@ -338,7 +338,7 @@ export default class Selection {
 	/**
 	 * Adds range to selection - creates copy of given range so it can be safely used and modified.
 	 *
-	 * Throws {@link utils.CKEditorError CKEditorError} `view-selection-range-intersects` if added range intersects
+	 * Throws {@link utils.CKEditorError CKEditorError} `selection-range-intersects` if added range intersects
 	 * with ranges already stored in selection instance.
 	 *
 	 * @private
@@ -350,12 +350,12 @@ export default class Selection {
 				/**
 				 * Trying to add a range that intersects with another range from selection.
 				 *
-				 * @error view-selection-range-intersects
+				 * @error selection-range-intersects
 				 * @param {engine.view.Range} addedRange Range that was added to the selection.
 				 * @param {engine.view.Range} intersectingRange Range from selection that intersects with `addedRange`.
 				 */
 				throw new CKEditorError(
-					'view-selection-range-intersects: Trying to add a range that intersects with another range from selection.',
+					'selection-range-intersects: Trying to add a range that intersects with another range from selection.',
 					{ addedRange: range, intersectingRange: storedRange }
 				);
 			}

+ 2 - 2
packages/ckeditor5-engine/tests/model/selection.js

@@ -106,7 +106,7 @@ describe( 'Selection', () => {
 		it( 'should throw an error when range is invalid', () => {
 			expect( () => {
 				selection.addRange( { invalid: 'Range' } );
-			} ).to.throw( CKEditorError, 'model-selection-invalid-range: Invalid Range.' );
+			} ).to.throw( CKEditorError, 'selection-invalid-range: Invalid Range.' );
 		} );
 
 		it( 'should copy added ranges and store multiple ranges', () => {
@@ -500,7 +500,7 @@ describe( 'Selection', () => {
 		it( 'should throw an error when range is invalid', () => {
 			expect( () => {
 				selection.setRanges( [ { invalid: 'range' } ] );
-			} ).to.throw( CKEditorError, 'model-selection-invalid-range: Invalid Range.' );
+			} ).to.throw( CKEditorError, 'selection-invalid-range: Invalid Range.' );
 		} );
 
 		it( 'should remove all ranges and add given ranges', () => {

+ 4 - 4
packages/ckeditor5-engine/tests/view/selection.js

@@ -147,7 +147,7 @@ describe( 'Selection', () => {
 		it( 'should throw an error when range is invalid', () => {
 			expect( () => {
 				selection.addRange( { invalid: 'range' } );
-			} ).to.throw( CKEditorError, 'view-selection-invalid-range: Invalid Range.' );
+			} ).to.throw( CKEditorError, 'selection-invalid-range: Invalid Range.' );
 		} );
 
 		it( 'should add range to selection ranges', () => {
@@ -169,11 +169,11 @@ describe( 'Selection', () => {
 			selection.addRange( range1 );
 			expect( () => {
 				selection.addRange( range2 );
-			} ).to.throw( CKEditorError, 'view-selection-range-intersects' );
+			} ).to.throw( CKEditorError, 'selection-range-intersects' );
 
 			expect( () => {
 				selection.addRange( range1 );
-			} ).to.throw( CKEditorError, 'view-selection-range-intersects' );
+			} ).to.throw( CKEditorError, 'selection-range-intersects' );
 		} );
 	} );
 
@@ -337,7 +337,7 @@ describe( 'Selection', () => {
 		it( 'should throw an error when range is invalid', () => {
 			expect( () => {
 				selection.setRanges( [ { invalid: 'range' } ] );
-			} ).to.throw( CKEditorError, 'view-selection-invalid-range: Invalid Range.' );
+			} ).to.throw( CKEditorError, 'selection-invalid-range: Invalid Range.' );
 		} );
 
 		it( 'should add ranges and fire change event', ( done ) => {