Skip to content

Commit

Permalink
fix: cryptic error message in Node.of() (#17)
Browse files Browse the repository at this point in the history
When `Node.of()` is called with an object that does not really extend `Construct`, we can't find the associated construct node. This change improves the error message to provide some hint for why this could happen.

Fixes #16
Related aws/aws-cdk#6885
  • Loading branch information
Elad Ben-Israel authored Mar 22, 2020
1 parent d3d908e commit 7db507b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Node {
public static of(construct: IConstruct): Node {
const node = (construct as any)[CONSTRUCT_NODE_PROPERTY_SYMBOL] as Node;
if (!node) {
throw new Error(`construct does not have an associated node`);
throw new Error(`construct does not have an associated node. All constructs must extend the "Construct" base class`);
}

return node;
Expand Down

0 comments on commit 7db507b

Please sign in to comment.