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

Method getContext

src/construct.ts:269–279  ·  view source on GitHub ↗

* Retrieves a value from tree context if present. Otherwise, would throw an error. * * Context is usually initialized at the root, but can be overridden at any point in the tree. * * @param key The context key * @returns The context value or throws error if there is no context value f

(key: string)

Source from the content-addressed store, hash-verified

267 * @returns The context value or throws error if there is no context value for this key
268 */
269 public getContext(key: string): any {
270 const value = this._context?.[key];
271
272 if (value !== undefined) { return value; }
273
274 if (value === undefined && !this.scope?.node) {
275 throw new Error(`No context value present for ${key} key`);
276 }
277
278 return this.scope && this.scope.node.getContext(key);
279 }
280
281 /**
282 * Retrieves the all context of a node from tree context.

Callers 1

construct.test.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected