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

Method getContext

src/construct.ts:243–253  ·  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

241 * @returns The context value or throws error if there is no context value for this key
242 */
243 public getContext(key: string): any {
244 const value = this._context?.[key];
245
246 if (value !== undefined) { return value; }
247
248 if (value === undefined && !this.scope?.node) {
249 throw new Error(`No context value present for ${key} key`);
250 }
251
252 return this.scope && this.scope.node.getContext(key);
253 }
254
255 /**
256 * 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