Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 598bc78

Browse files
committed
More error documentation improvements.
1 parent 3a95e2f commit 598bc78

14 files changed

+50
-31
lines changed

src/conversion/buildmodelconverter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,12 @@ class ModelConverterBuilder {
315315

316316
if ( this._from.type != 'marker' ) {
317317
/**
318-
* To highlight conversion is supported only for model markers.
318+
* Conversion to a highlight is supported only from model markers.
319319
*
320320
* @error build-model-converter-non-marker-to-highlight
321321
*/
322322
throw new CKEditorError(
323-
'build-model-converter-non-marker-to-highlight: Conversion to highlight is supported ' +
323+
'build-model-converter-non-marker-to-highlight: Conversion to a highlight is supported ' +
324324
'only from model markers.'
325325
);
326326
}

src/conversion/viewconsumable.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,16 @@ class ViewElementConsumables {
490490
for ( const name of items ) {
491491
if ( type === 'attribute' && ( name === 'class' || name === 'style' ) ) {
492492
/**
493-
* Class and style attributes should be handled separately.
493+
* Class and style attributes should be handled separately in
494+
* {@link module:engine/conversion/viewconsumable~ViewConsumable#add `ViewConsumable#add()`}.
495+
*
496+
* What you have done is trying to use:
497+
*
498+
* consumables.add( { attribute: [ 'class', 'style' ] } );
499+
*
500+
* While each class and style should be registered separately:
501+
*
502+
* consumables.add( { class: 'some-class', style: 'font-weight' } );
494503
*
495504
* @error viewconsumable-invalid-attribute
496505
*/

src/conversion/viewconversiondispatcher.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ export default class ViewConversionDispatcher {
184184
// Handle incorrect `data.output`.
185185
if ( data.output && !( data.output instanceof ModelNode || data.output instanceof ModelDocumentFragment ) ) {
186186
/**
187-
* Dropped incorrect conversion result.
187+
* Incorrect conversion result was dropped.
188188
*
189189
* Item may be converted to either {@link module:engine/model/node~Node model node} or
190190
* {@link module:engine/model/documentfragment~DocumentFragment model document fragment}.
191191
*
192192
* @error view-conversion-dispatcher-incorrect-result
193193
*/
194-
log.warn( 'view-conversion-dispatcher-incorrect-result: Dropped incorrect conversion result.', [ input, data.output ] );
194+
log.warn( 'view-conversion-dispatcher-incorrect-result: Incorrect conversion result was dropped.', [ input, data.output ] );
195195

196196
return null;
197197
}

src/model/delta/markerdelta.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ register( 'removeMarker', function( markerOrName ) {
103103

104104
if ( !this.document.markers.has( name ) ) {
105105
/**
106-
* Trying to remove marker that does not exist.
106+
* Trying to remove marker which does not exist.
107107
*
108108
* @error batch-removeMarker-no-marker
109109
*/
110-
throw new CKEditorError( 'batch-removeMarker-no-marker: Trying to remove marker that does not exist.' );
110+
throw new CKEditorError( 'batch-removeMarker-no-marker: Trying to remove marker which does not exist.' );
111111
}
112112

113113
const oldRange = this.document.markers.get( name ).getRange();

src/model/document.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export default class Document {
116116
for ( const range of this.selection.getRanges() ) {
117117
if ( !this._validateSelectionRange( range ) ) {
118118
/**
119-
* Range from document selection starts or ends at incorrect position.
119+
* Range from {@link module:engine/model/documentselection~DocumentSelection document selection}
120+
* starts or ends at incorrect position.
120121
*
121122
* @error document-selection-wrong-position
122123
* @param {module:engine/model/range~Range} range

src/model/documentselection.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,15 @@ export default class DocumentSelection extends Selection {
262262
*/
263263
static createFromSelection() {
264264
/**
265+
* Cannot create a new `DocumentSelection` instance.
266+
*
265267
* `DocumentSelection#createFromSelection()` is not available. There can be only one
266268
* `DocumentSelection` per document instance, so creating new `DocumentSelection`s this way
267269
* would be unsafe.
268270
*
269271
* @error documentselection-cannot-create
270272
*/
271-
throw new CKEditorError( 'documentselection-cannot-create: Cannot create new DocumentSelection instance.' );
273+
throw new CKEditorError( 'documentselection-cannot-create: Cannot create a new DocumentSelection instance.' );
272274
}
273275

274276
/**

src/model/liveposition.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ export default class LivePosition extends Position {
4343

4444
if ( !this.root.is( 'rootElement' ) ) {
4545
/**
46-
* LivePosition root has to be an instance of RootElement.
46+
* LivePosition's root has to be an instance of RootElement.
4747
*
4848
* @error liveposition-root-not-rootelement
4949
*/
50-
throw new CKEditorError( 'model-liveposition-root-not-rootelement: LivePosition root has to be an instance of RootElement.' );
50+
throw new CKEditorError(
51+
'model-liveposition-root-not-rootelement: LivePosition\'s root has to be an instance of RootElement.'
52+
);
5153
}
5254

5355
/**

src/model/markercollection.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export default class MarkerCollection {
142142
}
143143

144144
/**
145-
* Destroys markers collection.
145+
* Destroys marker collection and all markers inside it.
146146
*/
147147
destroy() {
148148
for ( const marker of this._markers.values() ) {
@@ -176,7 +176,7 @@ export default class MarkerCollection {
176176
}
177177

178178
/**
179-
* Destroys marker.
179+
* Destroys the marker.
180180
*
181181
* @private
182182
* @param {module:engine/model/markercollection~Marker} marker Marker to destroy.
@@ -241,7 +241,7 @@ class Marker {
241241
*/
242242
constructor( name, liveRange ) {
243243
/**
244-
* Marker name.
244+
* Marker's name.
245245
*
246246
* @readonly
247247
* @member {String} #name
@@ -268,7 +268,7 @@ class Marker {
268268
*/
269269
getStart() {
270270
if ( !this._liveRange ) {
271-
throw new CKEditorError( 'marker-destroyed: Operating on destroyed marker instance.' );
271+
throw new CKEditorError( 'marker-destroyed: Cannot use a destroyed marker instance.' );
272272
}
273273

274274
return Position.createFromPosition( this._liveRange.start );
@@ -281,7 +281,7 @@ class Marker {
281281
*/
282282
getEnd() {
283283
if ( !this._liveRange ) {
284-
throw new CKEditorError( 'marker-destroyed: Operating on destroyed marker instance.' );
284+
throw new CKEditorError( 'marker-destroyed: Cannot use a destroyed marker instance.' );
285285
}
286286

287287
return Position.createFromPosition( this._liveRange.end );
@@ -301,7 +301,7 @@ class Marker {
301301
*/
302302
getRange() {
303303
if ( !this._liveRange ) {
304-
throw new CKEditorError( 'marker-destroyed: Operating on destroyed marker instance.' );
304+
throw new CKEditorError( 'marker-destroyed: Cannot use a destroyed marker instance.' );
305305
}
306306

307307
return Range.createFromRange( this._liveRange );
@@ -339,7 +339,7 @@ class Marker {
339339
mix( Marker, EmitterMixin );
340340

341341
/**
342-
* Operating on destroyed marker instance.
342+
* Cannot use a {@link module:engine/model/markercollection~MarkerCollection#destroy destroyed marker} instance.
343343
*
344344
* @error marker-destroyed
345345
*/

src/model/node.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,5 +405,7 @@ export default class Node {
405405
/**
406406
* The node's parent does not contain this node.
407407
*
408+
* This error may be thrown from corrupted trees.
409+
*
408410
* @error model-node-not-found-in-parent
409411
*/

src/model/position.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ export default class Position {
4545
constructor( root, path ) {
4646
if ( !root.is( 'element' ) && !root.is( 'documentFragment' ) ) {
4747
/**
48-
* Position root invalid.
48+
* Position root is invalid.
49+
*
50+
* Positions can only be anchored in elements or document fragments.
4951
*
5052
* @error model-position-root-invalid
5153
*/
@@ -54,12 +56,12 @@ export default class Position {
5456

5557
if ( !( path instanceof Array ) || path.length === 0 ) {
5658
/**
57-
* Position path must be an Array with at least one item.
59+
* Position path must be an array with at least one item.
5860
*
5961
* @error model-position-path-incorrect
6062
* @param path
6163
*/
62-
throw new CKEditorError( 'model-position-path-incorrect: Position path must be an Array with at least one item.', { path } );
64+
throw new CKEditorError( 'model-position-path-incorrect: Position path must be an array with at least one item.', { path } );
6365
}
6466

6567
// Normalize the root and path (if element was passed).
@@ -686,7 +688,7 @@ export default class Position {
686688
static createAfter( item ) {
687689
if ( !item.parent ) {
688690
/**
689-
* You can not make position after root.
691+
* You can not make a position after a root element.
690692
*
691693
* @error model-position-after-root
692694
* @param {module:engine/model/item~Item} root
@@ -706,7 +708,7 @@ export default class Position {
706708
static createBefore( item ) {
707709
if ( !item.parent ) {
708710
/**
709-
* You can not make position before root.
711+
* You can not make a position before a root element.
710712
*
711713
* @error model-position-before-root
712714
* @param {module:engine/model/item~Item} root

0 commit comments

Comments
 (0)