Skip to content

Commit

Permalink
docs(core): findChild gets direct child only (#3512)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirskiy authored and Elad Ben-Israel committed Aug 6, 2019
1 parent 297d91a commit 75d06fd
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions packages/@aws-cdk/core/lib/construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,17 @@ export class ConstructNode {
}

/**
* Return a descendant by path
* Return a direct child by id
*
* Throws an error if the descendant is not found.
* Throws an error if the child is not found.
*
* Note that if the original ID of the construct you are looking for contained
* a '/', then it would have been replaced by '--'.
*
* @param path Relative path of a direct or indirect child
* @returns Child with the given path.
* @param id Identifier of direct child
* @returns Child with the given id.
*/
public findChild(path: string): IConstruct {
const ret = this.tryFindChild(path);
public findChild(id: string): IConstruct {
const ret = this.tryFindChild(id);
if (!ret) {
throw new Error(`No child with path: '${path}'`);
throw new Error(`No child with id: '${id}'`);
}
return ret;
}
Expand Down

0 comments on commit 75d06fd

Please sign in to comment.