@@ -4,7 +4,7 @@ import { CfnFileSystem, CfnMountTarget } from './efs.generated';
4
4
import * as ec2 from '../../aws-ec2' ;
5
5
import * as iam from '../../aws-iam' ;
6
6
import * as kms from '../../aws-kms' ;
7
- import { ArnFormat , FeatureFlags , Lazy , RemovalPolicy , Resource , Size , Stack , Tags , Token } from '../../core' ;
7
+ import { ArnFormat , FeatureFlags , Lazy , RemovalPolicy , Resource , Size , Stack , Tags , Token , ValidationError } from '../../core' ;
8
8
import { addConstructMetadata , MethodMetadata } from '../../core/lib/metadata-resource' ;
9
9
import * as cxapi from '../../cx-api' ;
10
10
@@ -735,21 +735,21 @@ export class FileSystem extends FileSystemBase {
735
735
this . props = props ;
736
736
737
737
if ( props . performanceMode === PerformanceMode . MAX_IO && props . oneZone ) {
738
- throw new Error ( 'performanceMode MAX_IO is not supported for One Zone file systems.' ) ;
738
+ throw new ValidationError ( 'performanceMode MAX_IO is not supported for One Zone file systems.' , this ) ;
739
739
}
740
740
741
741
if ( props . oneZone ) { this . oneZoneValidation ( ) ; }
742
742
743
743
if ( props . throughputMode === ThroughputMode . PROVISIONED && props . provisionedThroughputPerSecond === undefined ) {
744
- throw new Error ( 'Property provisionedThroughputPerSecond is required when throughputMode is PROVISIONED' ) ;
744
+ throw new ValidationError ( 'Property provisionedThroughputPerSecond is required when throughputMode is PROVISIONED' , this ) ;
745
745
}
746
746
747
747
if ( props . throughputMode === ThroughputMode . ELASTIC && props . performanceMode === PerformanceMode . MAX_IO ) {
748
- throw new Error ( 'ThroughputMode ELASTIC is not supported for file systems with performanceMode MAX_IO' ) ;
748
+ throw new ValidationError ( 'ThroughputMode ELASTIC is not supported for file systems with performanceMode MAX_IO' , this ) ;
749
749
}
750
750
751
751
if ( props . replicationConfiguration && props . replicationOverwriteProtection === ReplicationOverwriteProtection . DISABLED ) {
752
- throw new Error ( 'Cannot configure \'replicationConfiguration\' when \'replicationOverwriteProtection\' is set to \'DISABLED\'' ) ;
752
+ throw new ValidationError ( 'Cannot configure \'replicationConfiguration\' when \'replicationOverwriteProtection\' is set to \'DISABLED\'' , this ) ;
753
753
}
754
754
755
755
// we explicitly use 'undefined' to represent 'false' to maintain backwards compatibility since
@@ -891,13 +891,13 @@ export class FileSystem extends FileSystemBase {
891
891
private oneZoneValidation ( ) {
892
892
// validate when props.oneZone is enabled
893
893
if ( this . props . vpcSubnets && ! this . props . vpcSubnets . availabilityZones ) {
894
- throw new Error ( 'When oneZone is enabled and vpcSubnets defined, vpcSubnets.availabilityZones can not be undefined.' ) ;
894
+ throw new ValidationError ( 'When oneZone is enabled and vpcSubnets defined, vpcSubnets.availabilityZones can not be undefined.' , this ) ;
895
895
}
896
896
// when vpcSubnets.availabilityZones is defined
897
897
if ( this . props . vpcSubnets && this . props . vpcSubnets . availabilityZones ) {
898
898
// it has to be only one az
899
899
if ( this . props . vpcSubnets . availabilityZones ?. length !== 1 ) {
900
- throw new Error ( 'When oneZone is enabled, vpcSubnets.availabilityZones should exactly have one zone.' ) ;
900
+ throw new ValidationError ( 'When oneZone is enabled, vpcSubnets.availabilityZones should exactly have one zone.' , this ) ;
901
901
}
902
902
// it has to be in availabilityZones
903
903
// but we only check this when vpc.availabilityZones are valid(not dummy values nore unresolved tokens)
@@ -906,7 +906,7 @@ export class FileSystem extends FileSystemBase {
906
906
if ( this . props . vpc . availabilityZones . every ( isNotUnresolvedToken ) &&
907
907
this . props . vpc . availabilityZones . every ( isNotDummy ) &&
908
908
! this . props . vpc . availabilityZones . includes ( this . props . vpcSubnets . availabilityZones [ 0 ] ) ) {
909
- throw new Error ( 'vpcSubnets.availabilityZones specified is not in vpc.availabilityZones.' ) ;
909
+ throw new ValidationError ( 'vpcSubnets.availabilityZones specified is not in vpc.availabilityZones.' , this ) ;
910
910
}
911
911
}
912
912
}
@@ -950,7 +950,7 @@ class ImportedFileSystem extends FileSystemBase {
950
950
addConstructMetadata ( this , attrs ) ;
951
951
952
952
if ( ! ! attrs . fileSystemId === ! ! attrs . fileSystemArn ) {
953
- throw new Error ( 'One of fileSystemId or fileSystemArn, but not both, must be provided.' ) ;
953
+ throw new ValidationError ( 'One of fileSystemId or fileSystemArn, but not both, must be provided.' , this ) ;
954
954
}
955
955
956
956
this . fileSystemArn = attrs . fileSystemArn ?? Stack . of ( scope ) . formatArn ( {
@@ -962,7 +962,7 @@ class ImportedFileSystem extends FileSystemBase {
962
962
const parsedArn = Stack . of ( scope ) . splitArn ( this . fileSystemArn , ArnFormat . SLASH_RESOURCE_NAME ) ;
963
963
964
964
if ( ! parsedArn . resourceName ) {
965
- throw new Error ( `Invalid FileSystem Arn ${ this . fileSystemArn } ` ) ;
965
+ throw new ValidationError ( `Invalid FileSystem Arn ${ this . fileSystemArn } ` , this ) ;
966
966
}
967
967
968
968
this . fileSystemId = attrs . fileSystemId ?? parsedArn . resourceName ;
0 commit comments