Skip to content

Commit df895f1

Browse files
fix: add error code names to ValidationError calls after merging main
1 parent 368f92a commit df895f1

File tree

1 file changed

+7
-7
lines changed
  • packages/aws-cdk-lib/aws-ec2/lib

1 file changed

+7
-7
lines changed

packages/aws-cdk-lib/aws-ec2/lib/nat.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ export class NatGatewayProvider extends NatProvider {
403403
const seconds = this.props.maxDrainDuration.toSeconds({ integral: false });
404404
if (seconds < 1 || seconds > 4000) {
405405
throw new UnscopedValidationError(
406-
`\`maxDrainDuration\` must be between 1 and 4000 seconds, got ${seconds} seconds.`,
406+
'InvalidMaxDrainDuration', `\`maxDrainDuration\` must be between 1 and 4000 seconds, got ${seconds} seconds.`,
407407
);
408408
}
409409
}
@@ -467,24 +467,24 @@ export class RegionalNatGatewayProvider extends NatProvider {
467467

468468
if (this.props.allocationId && this.props.eip) {
469469
throw new UnscopedValidationError(
470-
'Cannot specify both `allocationId` and `eip`. Use one or the other.',
470+
'CannotSpecifyBothAllocationIdAndEip', 'Cannot specify both `allocationId` and `eip`. Use one or the other.',
471471
);
472472
}
473473

474474
if (this.props.availabilityZoneAddresses) {
475475
if (this.props.availabilityZoneAddresses.length === 0) {
476476
throw new UnscopedValidationError(
477-
'`availabilityZoneAddresses` cannot be an empty array.',
477+
'EmptyAvailabilityZoneAddresses', '`availabilityZoneAddresses` cannot be an empty array.',
478478
);
479479
}
480480
if (this.props.availabilityZoneAddresses.some(az => !az.availabilityZone && !az.availabilityZoneId)) {
481481
throw new UnscopedValidationError(
482-
'Either `availabilityZone` or `availabilityZoneId` must be specified in `AvailabilityZoneAddress`.',
482+
'MissingAvailabilityZoneOrId', 'Either `availabilityZone` or `availabilityZoneId` must be specified in `AvailabilityZoneAddress`.',
483483
);
484484
}
485485
if (this.props.availabilityZoneAddresses.some(az => az.allocationIds.length === 0)) {
486486
throw new UnscopedValidationError(
487-
'`allocationIds` cannot be an empty array in `AvailabilityZoneAddress`.',
487+
'EmptyAllocationIds', '`allocationIds` cannot be an empty array in `AvailabilityZoneAddress`.',
488488
);
489489
}
490490
}
@@ -493,7 +493,7 @@ export class RegionalNatGatewayProvider extends NatProvider {
493493
const seconds = this.props.maxDrainDuration.toSeconds({ integral: false });
494494
if (seconds < 1 || seconds > 4000) {
495495
throw new UnscopedValidationError(
496-
`\`maxDrainDuration\` must be between 1 and 4000 seconds, got ${seconds} seconds.`,
496+
'InvalidMaxDrainDuration', `\`maxDrainDuration\` must be between 1 and 4000 seconds, got ${seconds} seconds.`,
497497
);
498498
}
499499
}
@@ -534,7 +534,7 @@ export class RegionalNatGatewayProvider extends NatProvider {
534534

535535
public configureSubnet(subnet: PrivateSubnet) {
536536
if (!this.natGateway) {
537-
throw new UnscopedValidationError('Cannot configure subnet before configuring NAT gateway');
537+
throw new UnscopedValidationError('CannotConfigureSubnetBeforeNat', 'Cannot configure subnet before configuring NAT gateway');
538538
}
539539
// All private subnets use the same regional NAT gateway ID
540540
subnet.addRoute('DefaultRoute', {

0 commit comments

Comments
 (0)