Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(core): update findChild, gets direct child only #3512

Merged
merged 1 commit into from
Aug 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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