aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
4 lines (3 loc) • 3.82 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ExecutionError=exports.AssumptionError=exports.UnscopedValidationError=exports.ValidationError=exports.Errors=void 0;const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var helpers_internal_1=()=>{var tmp=require("./helpers-internal");return helpers_internal_1=()=>tmp,tmp};const CONSTRUCT_ERROR_SYMBOL=Symbol.for("@aws-cdk/core.SynthesisError"),VALIDATION_ERROR_SYMBOL=Symbol.for("@aws-cdk/core.ValidationError"),ASSERTION_ERROR_SYMBOL=Symbol.for("@aws-cdk/assertions.AssertionError"),ASSEMBLY_ERROR_SYMBOL=Symbol.for("@aws-cdk/cx-api.CloudAssemblyError"),ASSUMPTION_ERROR_SYMBOL=Symbol.for("@aws-cdk/core.AssumptionError"),EXECUTION_ERROR_SYMBOL=Symbol.for("@aws-cdk/core.ExecutionError");class Errors{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.Errors",version:"2.233.0"};static isConstructError(x){return x!==null&&typeof x=="object"&&CONSTRUCT_ERROR_SYMBOL in x}static isValidationError(x){return Errors.isConstructError(x)&&VALIDATION_ERROR_SYMBOL in x}static isAssertionError(x){return Errors.isConstructError(x)&&ASSERTION_ERROR_SYMBOL in x}static isCloudAssemblyError(x){return x!==null&&typeof x=="object"&&ASSEMBLY_ERROR_SYMBOL in x}static isExecutionError(x){return x!==null&&typeof x=="object"&&EXECUTION_ERROR_SYMBOL in x}static isAssumptionError(x){return x!==null&&typeof x=="object"&&ASSUMPTION_ERROR_SYMBOL in x}}exports.Errors=Errors;class ConstructError extends Error{#time;#constructPath;#constructInfo;get time(){return this.#time}get level(){return"error"}get constructPath(){return this.#constructPath}get constructInfo(){return this.#constructInfo}constructor(msg,scope,name){if(super(msg),Object.setPrototypeOf(this,ConstructError.prototype),Object.defineProperty(this,CONSTRUCT_ERROR_SYMBOL,{value:!0}),this.name=name??new.target.name,this.#time=new Date().toISOString(),this.#constructPath=scope?.node.path,scope){Error.captureStackTrace(this,scope.constructor);try{this.#constructInfo=scope?(0,helpers_internal_1().constructInfoFromConstruct)(scope):void 0}catch{}}const stack=[`${this.name}: ${this.message}`];this.constructInfo?stack.push(`in ${this.constructInfo?.fqn} at [${this.constructPath}]`):stack.push(`in [${this.constructPath}]`),this.stack&&stack.push(this.stack),this.stack=this.constructStack(this.stack)}constructStack(prev){const indent=" ".repeat(4),stack=[`${this.name}: ${this.message}`];return this.constructInfo?stack.push(`${indent}at path [${this.constructPath}] in ${this.constructInfo?.fqn}`):stack.push(`${indent}at path [${this.constructPath}]`),prev&&(stack.push(""),stack.push(...prev.split(`
`).slice(1))),stack.join(`
`)}}class ValidationError extends ConstructError{get type(){return"validation"}constructor(msg,scope){super(msg,scope),Object.setPrototypeOf(this,ValidationError.prototype),Object.defineProperty(this,VALIDATION_ERROR_SYMBOL,{value:!0})}}exports.ValidationError=ValidationError;class UnscopedValidationError extends ConstructError{get type(){return"validation"}constructor(msg){super(msg,void 0,ValidationError.name),Object.setPrototypeOf(this,UnscopedValidationError.prototype),Object.defineProperty(this,VALIDATION_ERROR_SYMBOL,{value:!0})}}exports.UnscopedValidationError=UnscopedValidationError;class AssumptionError extends ConstructError{get type(){return"assumption"}constructor(msg){super(msg,void 0,AssumptionError.name),Object.setPrototypeOf(this,AssumptionError.prototype),Object.defineProperty(this,ASSUMPTION_ERROR_SYMBOL,{value:!0})}}exports.AssumptionError=AssumptionError;class ExecutionError extends ConstructError{get type(){return"exec"}constructor(msg){super(msg,void 0,ExecutionError.name),Object.setPrototypeOf(this,ExecutionError.prototype),Object.defineProperty(this,EXECUTION_ERROR_SYMBOL,{value:!0})}}exports.ExecutionError=ExecutionError;