You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(s3): throw ValidationError instead of untyped errors (#33031)
### Issue
`aws-s3` for #32569
### Description of changes
Added an `UnscopedValidationError` for situations where now scope is
available. This is to be used sparsely as it's less useful for users.
### Describe any new or updated permissions being added
n/a
### Description of how you validated changes
Existing tests. Exemptions granted as this is basically a refactor of
existing code.
### Checklist
- [x] My code adheres to the [CONTRIBUTING
GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and
[DESIGN
GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*
thrownewError('\'enforceSSL\' must be enabled for \'minimumTLSVersion\' to be applied');
2251
+
thrownewValidationError('\'enforceSSL\' must be enabled for \'minimumTLSVersion\' to be applied',this);
2251
2252
}
2252
2253
2253
2254
if(props.serverAccessLogsBucketinstanceofBucket){
@@ -2281,15 +2282,15 @@ export class Bucket extends BucketBase {
2281
2282
2282
2283
if(props.publicReadAccess){
2283
2284
if(props.blockPublicAccess===undefined){
2284
-
thrownewError('Cannot use \'publicReadAccess\' property on a bucket without allowing bucket-level public access through \'blockPublicAccess\' property.');
2285
+
thrownewValidationError('Cannot use \'publicReadAccess\' property on a bucket without allowing bucket-level public access through \'blockPublicAccess\' property.',this);
2285
2286
}
2286
2287
2287
2288
this.grantPublicAccess();
2288
2289
}
2289
2290
2290
2291
if(props.autoDeleteObjects){
2291
2292
if(props.removalPolicy!==RemovalPolicy.DESTROY){
2292
-
thrownewError('Cannot use \'autoDeleteObjects\' property on a bucket without setting removal policy to \'DESTROY\'.');
2293
+
thrownewValidationError('Cannot use \'autoDeleteObjects\' property on a bucket without setting removal policy to \'DESTROY\'.',this);
2293
2294
}
2294
2295
2295
2296
this.enableAutoDeleteObjects();
@@ -2409,12 +2410,12 @@ export class Bucket extends BucketBase {
2409
2410
2410
2411
// if encryption key is set, encryption must be set to KMS or DSSE.
// ExpiredObjectDeleteMarker cannot be specified with ExpirationInDays, ExpirationDate, or TagFilters.
2524
-
thrownewError('ExpiredObjectDeleteMarker cannot be specified with expiration, ExpirationDate, or TagFilters.');
2525
+
thrownewValidationError('ExpiredObjectDeleteMarker cannot be specified with expiration, ExpirationDate, or TagFilters.',self);
2525
2526
}
2526
2527
2527
2528
if(
@@ -2534,7 +2535,7 @@ export class Bucket extends BucketBase {
2534
2535
rule.noncurrentVersionTransitions===undefined&&
2535
2536
rule.transitions===undefined
2536
2537
){
2537
-
thrownewError('All rules for `lifecycleRules` must have at least one of the following properties: `abortIncompleteMultipartUploadAfter`, `expiration`, `expirationDate`, `expiredObjectDeleteMarker`, `noncurrentVersionExpiration`, `noncurrentVersionsToRetain`, `noncurrentVersionTransitions`, or `transitions`');
2538
+
thrownewValidationError('All rules for `lifecycleRules` must have at least one of the following properties: `abortIncompleteMultipartUploadAfter`, `expiration`, `expirationDate`, `expiredObjectDeleteMarker`, `noncurrentVersionExpiration`, `noncurrentVersionsToRetain`, `noncurrentVersionTransitions`, or `transitions`',self);
2538
2539
}
2539
2540
2540
2541
constx: CfnBucket.RuleProperty={
@@ -2580,7 +2581,7 @@ export class Bucket extends BucketBase {
thrownewError('Default bucket encryption with KMS managed or DSSE managed key is not supported for Server Access Logging target buckets');
2584
+
thrownewValidationError('Default bucket encryption with KMS managed or DSSE managed key is not supported for Server Access Logging target buckets',this);
2584
2585
}
2585
2586
2586
2587
// When there is an encryption key exists for the server access logs bucket, grant permission to the S3 logging SP.
@@ -2657,7 +2658,7 @@ export class Bucket extends BucketBase {
thrownewError(`inventoryId should not exceed 64 characters and should not contain special characters except . and -, got ${inventory.inventoryId}`);
2941
+
thrownewValidationError(`inventoryId should not exceed 64 characters and should not contain special characters except . and -, got ${inventory.inventoryId}`,this);
0 commit comments