MCPcopy Create free account
hub / github.com/aws/constructs / addChild

Method addChild

src/construct.ts:502–524  ·  view source on GitHub ↗

* Adds a child construct to this node. * * @param child The child construct * @param childName The type name of the child construct. * @returns The resolved path part name of the child

(child: Construct, childName: string)

Source from the content-addressed store, hash-verified

500 * @returns The resolved path part name of the child
501 */
502 private addChild(child: Construct, childName: string) {
503 if (this.locked) {
504
505 // special error if root is locked
506 if (!this.path) {
507 throw new Error('Cannot add children during synthesis');
508 }
509
510 throw new Error(`Cannot add children to "${this.path}" during synthesis`);
511 }
512
513 if (!this._children) {
514 this._children = {};
515 }
516
517 if (this._children[childName]) {
518 const name = this.id ?? '';
519 const typeName = this.host.constructor.name;
520 throw new Error(`There is already a Construct with name '${childName}' in ${typeName}${name.length > 0 ? ' [' + name + ']' : ''}`);
521 }
522
523 this._children[childName] = child;
524 }
525}
526
527/**

Callers 1

constructorMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected