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

Method getContext

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

254 * @returns The context value or throws error if there is no context value for this key
255 */
256 public getContext(key: string): any {
257 const value = this._context?.[key];
258
259 if (value !== undefined) { return value; }
260
261 if (value === undefined && !this.scope?.node) {
262 throw new Error(`No context value present for ${key} key`);
263 }
264
265 return this.scope && this.scope.node.getContext(key);
266 }
267
268 /**
269 * 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