@@ -184,12 +184,12 @@ export abstract class Node extends Origin implements Destination {
184
184
return props [ name ] ?. child ? props [ name ] : undefined ;
185
185
}
186
186
187
- setChild ( name : string , child : Node ) : void {
187
+ setChild ( name : string | symbol , child : Node ) : void {
188
188
const containment = this . containment ( name ) ;
189
189
if ( ! containment ) {
190
- throw new Error ( "Not a containment: " + name ) ;
190
+ throw this . notAContainment ( name ) ;
191
191
} else if ( containment . multiple ) {
192
- throw new Error ( name + " is a collection, use addChild" ) ;
192
+ throw new Error ( name . toString ( ) + " is a collection, use addChild" ) ;
193
193
}
194
194
if ( child . parent && child . parent != this ) {
195
195
throw new Error ( "Child already has a different parent" ) ;
@@ -200,12 +200,12 @@ export abstract class Node extends Origin implements Destination {
200
200
this [ name ] = child . withParent ( this ) ;
201
201
}
202
202
203
- addChild ( name : string , child : Node ) : void {
203
+ addChild ( name : string | symbol , child : Node ) : void {
204
204
const containment = this . containment ( name ) ;
205
205
if ( ! containment ) {
206
- throw new Error ( "Not a containment: " + name ) ;
206
+ throw this . notAContainment ( name ) ;
207
207
} else if ( ! containment . multiple ) {
208
- throw new Error ( name + " is not a collection, use setChild" ) ;
208
+ throw new Error ( name . toString ( ) + " is not a collection, use setChild" ) ;
209
209
}
210
210
if ( child . parent && child . parent != this ) {
211
211
throw new Error ( "Child already has a different parent" ) ;
@@ -216,10 +216,14 @@ export abstract class Node extends Origin implements Destination {
216
216
this [ name ] . push ( child . withParent ( this ) ) ;
217
217
}
218
218
219
+ private notAContainment ( name : string | symbol ) {
220
+ return new Error ( `Not a containment: ${ name . toString ( ) } of ${ this . nodeDefinition ?. name || "<unknown>" } ` ) ;
221
+ }
222
+
219
223
getChild ( name : string | symbol , index ?: number ) : Node | undefined {
220
224
const containment = this . containment ( name ) ;
221
225
if ( ! containment ) {
222
- throw new Error ( "Not a containment: " + name . toString ( ) ) ;
226
+ throw this . notAContainment ( name ) ;
223
227
}
224
228
const raw = this . doGetChildOrChildren ( name ) ;
225
229
if ( containment . multiple ) {
@@ -271,7 +275,7 @@ export abstract class Node extends Origin implements Destination {
271
275
getChildrenWithRole ( name : string | symbol ) {
272
276
const containment = this . containment ( name ) ;
273
277
if ( ! containment ) {
274
- throw new Error ( "Not a containment: " + name . toString ( ) ) ;
278
+ throw this . notAContainment ( name ) ;
275
279
}
276
280
const raw = this . doGetChildOrChildren ( name ) ;
277
281
if ( containment . multiple ) {
0 commit comments