diff --git a/packages/aws-cdk-lib/aws-apigateway/lib/deployment.ts b/packages/aws-cdk-lib/aws-apigateway/lib/deployment.ts index 4c1b6f7adbf1a..ee2111d8ce067 100644 --- a/packages/aws-cdk-lib/aws-apigateway/lib/deployment.ts +++ b/packages/aws-cdk-lib/aws-apigateway/lib/deployment.ts @@ -3,7 +3,7 @@ import { CfnDeployment } from './apigateway.generated'; import { Method } from './method'; import { IRestApi, RestApi, SpecRestApi, RestApiBase } from './restapi'; import { Lazy, RemovalPolicy, Resource, CfnResource } from '../../core'; -import { UnscopedValidationError } from '../../core/lib/errors'; +import { ValidationError } from '../../core/lib/errors'; import { md5hash } from '../../core/lib/helpers-internal'; export interface DeploymentProps { @@ -169,7 +169,7 @@ class LatestDeploymentResource extends CfnDeployment { // if the construct is locked, it means we are already synthesizing and then // we can't modify the hash because we might have already calculated it. if (this.node.locked) { - throw new UnscopedValidationError('Cannot modify the logical ID when the construct is locked'); + throw new ValidationError('Cannot modify the logical ID when the construct is locked', this); } this.hashComponents.push(data); diff --git a/packages/aws-cdk-lib/aws-apigateway/lib/integration.ts b/packages/aws-cdk-lib/aws-apigateway/lib/integration.ts index fe02f36d32bee..ad246c9034b30 100644 --- a/packages/aws-cdk-lib/aws-apigateway/lib/integration.ts +++ b/packages/aws-cdk-lib/aws-apigateway/lib/integration.ts @@ -2,7 +2,7 @@ import { Method } from './method'; import { IVpcLink, VpcLink } from './vpc-link'; import * as iam from '../../aws-iam'; import { Lazy, Duration } from '../../core'; -import { UnscopedValidationError } from '../../core/lib/errors'; +import { UnscopedValidationError, ValidationError } from '../../core/lib/errors'; export interface IntegrationOptions { /** @@ -224,7 +224,7 @@ export class Integration { * Can be overridden by subclasses to allow the integration to interact with the method * being integrated, access the REST API object, method ARNs, etc. */ - public bind(_method: Method): IntegrationConfig { + public bind(method: Method): IntegrationConfig { let uri = this.props.uri; const options = this.props.options; @@ -236,12 +236,12 @@ export class Integration { if (vpcLink instanceof VpcLink) { const targets = vpcLink._targetDnsNames; if (targets.length > 1) { - throw new UnscopedValidationError("'uri' is required when there are more than one NLBs in the VPC Link"); + throw new ValidationError("'uri' is required when there are more than one NLBs in the VPC Link", method); } else { return `http://${targets[0]}`; } } else { - throw new UnscopedValidationError("'uri' is required when the 'connectionType' is VPC_LINK"); + throw new ValidationError("'uri' is required when the 'connectionType' is VPC_LINK", method); } }, }); diff --git a/packages/aws-cdk-lib/aws-apigateway/lib/integrations/stepfunctions.ts b/packages/aws-cdk-lib/aws-apigateway/lib/integrations/stepfunctions.ts index 6a575ee3ff321..70f5c03421631 100644 --- a/packages/aws-cdk-lib/aws-apigateway/lib/integrations/stepfunctions.ts +++ b/packages/aws-cdk-lib/aws-apigateway/lib/integrations/stepfunctions.ts @@ -5,7 +5,7 @@ import { AwsIntegration } from './aws'; import * as iam from '../../../aws-iam'; import * as sfn from '../../../aws-stepfunctions'; import { Token } from '../../../core'; -import { UnscopedValidationError } from '../../../core/lib/errors'; +import { ValidationError } from '../../../core/lib/errors'; import { IntegrationConfig, IntegrationOptions, PassthroughBehavior } from '../integration'; import { Method } from '../method'; import { Model } from '../model'; @@ -151,7 +151,7 @@ class StepFunctionsExecutionIntegration extends AwsIntegration { if (this.stateMachine instanceof sfn.StateMachine) { const stateMachineType = (this.stateMachine as sfn.StateMachine).stateMachineType; if (stateMachineType !== sfn.StateMachineType.EXPRESS) { - throw new UnscopedValidationError('State Machine must be of type "EXPRESS". Please use StateMachineType.EXPRESS as the stateMachineType'); + throw new ValidationError('State Machine must be of type "EXPRESS". Please use StateMachineType.EXPRESS as the stateMachineType', this.stateMachine); } //if not imported, extract the name from the CFN layer to reach the