8
0
Maciej Bukowski 6 лет назад
Родитель
Сommit
d201a54f19

+ 6 - 6
packages/ckeditor5-utils/src/collection.js

@@ -148,7 +148,7 @@ export default class Collection {
 				 *
 				 * @error collection-add-invalid-id
 				 */
-				throw new CKEditorError( 'collection-add-invalid-id' );
+				throw new CKEditorError( 'collection-add-invalid-id', this );
 			}
 
 			if ( this.get( itemId ) ) {
@@ -157,7 +157,7 @@ export default class Collection {
 				 *
 				 * @error collection-add-item-already-exists
 				 */
-				throw new CKEditorError( 'collection-add-item-already-exists' );
+				throw new CKEditorError( 'collection-add-item-already-exists', this );
 			}
 		} else {
 			item[ idProperty ] = itemId = uid();
@@ -172,7 +172,7 @@ export default class Collection {
 			 *
 			 * @error collection-add-item-bad-index
 			 */
-			throw new CKEditorError( 'collection-add-item-invalid-index' );
+			throw new CKEditorError( 'collection-add-item-invalid-index', this );
 		}
 
 		this._items.splice( index, 0, item );
@@ -203,7 +203,7 @@ export default class Collection {
 			 *
 			 * @error collection-get-invalid-arg
 			 */
-			throw new CKEditorError( 'collection-get-invalid-arg: Index or id must be given.' );
+			throw new CKEditorError( 'collection-get-invalid-arg: Index or id must be given.', this );
 		}
 
 		return item || null;
@@ -286,7 +286,7 @@ export default class Collection {
 			 *
 			 * @error collection-remove-404
 			 */
-			throw new CKEditorError( 'collection-remove-404: Item not found.' );
+			throw new CKEditorError( 'collection-remove-404: Item not found.', this );
 		}
 
 		this._items.splice( index, 1 );
@@ -459,7 +459,7 @@ export default class Collection {
 			 *
 			 * @error collection-bind-to-rebind
 			 */
-			throw new CKEditorError( 'collection-bind-to-rebind: The collection cannot be bound more than once.' );
+			throw new CKEditorError( 'collection-bind-to-rebind: The collection cannot be bound more than once.', this );
 		}
 
 		this._bindToCollection = externalCollection;

+ 1 - 1
packages/ckeditor5-utils/src/keyboard.js

@@ -60,7 +60,7 @@ export function getCode( key ) {
 			 * @errror keyboard-unknown-key
 			 * @param {String} key
 			 */
-			throw new CKEditorError( 'keyboard-unknown-key: Unknown key name.', { key } );
+			throw new CKEditorError( 'keyboard-unknown-key: Unknown key name.', this, { key } );
 		}
 	} else {
 		keyCode = key.keyCode +

+ 15 - 11
packages/ckeditor5-utils/src/observablemixin.js

@@ -62,7 +62,7 @@ const ObservableMixin = {
 			 *
 			 * @error observable-set-cannot-override
 			 */
-			throw new CKEditorError( 'observable-set-cannot-override: Cannot override an existing property.' );
+			throw new CKEditorError( 'observable-set-cannot-override: Cannot override an existing property.', this );
 		}
 
 		Object.defineProperty( this, name, {
@@ -107,7 +107,7 @@ const ObservableMixin = {
 			 *
 			 * @error observable-bind-wrong-properties
 			 */
-			throw new CKEditorError( 'observable-bind-wrong-properties: All properties must be strings.' );
+			throw new CKEditorError( 'observable-bind-wrong-properties: All properties must be strings.', this );
 		}
 
 		if ( ( new Set( bindProperties ) ).size !== bindProperties.length ) {
@@ -116,7 +116,7 @@ const ObservableMixin = {
 			 *
 			 * @error observable-bind-duplicate-properties
 			 */
-			throw new CKEditorError( 'observable-bind-duplicate-properties: Properties must be unique.' );
+			throw new CKEditorError( 'observable-bind-duplicate-properties: Properties must be unique.', this );
 		}
 
 		initObservable( this );
@@ -130,7 +130,7 @@ const ObservableMixin = {
 				 *
 				 * @error observable-bind-rebind
 				 */
-				throw new CKEditorError( 'observable-bind-rebind: Cannot bind the same property more that once.' );
+				throw new CKEditorError( 'observable-bind-rebind: Cannot bind the same property more that once.', this );
 			}
 		} );
 
@@ -186,7 +186,7 @@ const ObservableMixin = {
 				 *
 				 * @error observable-unbind-wrong-properties
 				 */
-				throw new CKEditorError( 'observable-unbind-wrong-properties: Properties must be strings.' );
+				throw new CKEditorError( 'observable-unbind-wrong-properties: Properties must be strings.', this );
 			}
 
 			unbindProperties.forEach( propertyName => {
@@ -246,6 +246,7 @@ const ObservableMixin = {
 			 */
 			throw new CKEditorError(
 				'observablemixin-cannot-decorate-undefined: Cannot decorate an undefined method.',
+				this,
 				{ object: this, methodName }
 			);
 		}
@@ -380,7 +381,7 @@ function bindTo( ...args ) {
 		 *
 		 * @error observable-bind-no-callback
 		 */
-		throw new CKEditorError( 'observable-bind-to-no-callback: Binding multiple observables only possible with callback.' );
+		throw new CKEditorError( 'observable-bind-to-no-callback: Binding multiple observables only possible with callback.', this );
 	}
 
 	// Eliminate A.bind( 'x', 'y' ).to( B, callback )
@@ -390,7 +391,10 @@ function bindTo( ...args ) {
 		 *
 		 * @error observable-bind-to-extra-callback
 		 */
-		throw new CKEditorError( 'observable-bind-to-extra-callback: Cannot bind multiple properties and use a callback in one binding.' );
+		throw new CKEditorError(
+			'observable-bind-to-extra-callback: Cannot bind multiple properties and use a callback in one binding.',
+			this
+		);
 	}
 
 	parsedArgs.to.forEach( to => {
@@ -401,7 +405,7 @@ function bindTo( ...args ) {
 			 *
 			 * @error observable-bind-to-properties-length
 			 */
-			throw new CKEditorError( 'observable-bind-to-properties-length: The number of properties must match.' );
+			throw new CKEditorError( 'observable-bind-to-properties-length: The number of properties must match.', this );
 		}
 
 		// When no to.properties specified, observing source properties instead i.e.
@@ -442,7 +446,7 @@ function bindToMany( observables, attribute, callback ) {
 		 *
 		 * @error observable-bind-to-many-not-one-binding
 		 */
-		throw new CKEditorError( 'observable-bind-to-many-not-one-binding: Cannot bind multiple properties with toMany().' );
+		throw new CKEditorError( 'observable-bind-to-many-not-one-binding: Cannot bind multiple properties with toMany().', this );
 	}
 
 	this.to(
@@ -501,7 +505,7 @@ function parseBindToArgs( ...args ) {
 		 *
 		 * @error observable-bind-to-parse-error
 		 */
-		throw new CKEditorError( 'observable-bind-to-parse-error: Invalid argument syntax in `to()`.' );
+		throw new CKEditorError( 'observable-bind-to-parse-error: Invalid argument syntax in `to()`.', this );
 	}
 
 	const parsed = { to: [] };
@@ -518,7 +522,7 @@ function parseBindToArgs( ...args ) {
 			lastObservable = { observable: a, properties: [] };
 			parsed.to.push( lastObservable );
 		} else {
-			throw new CKEditorError( 'observable-bind-to-parse-error: Invalid argument syntax in `to()`.' );
+			throw new CKEditorError( 'observable-bind-to-parse-error: Invalid argument syntax in `to()`.', this );
 		}
 	} );