@@ -3,7 +3,7 @@ import { SubscriptionProps } from './subscription';
3
3
import * as iam from '../../aws-iam' ;
4
4
import * as sns from '../../aws-sns' ;
5
5
import * as sqs from '../../aws-sqs' ;
6
- import { ArnFormat , FeatureFlags , Names , Stack , Token } from '../../core' ;
6
+ import { ArnFormat , FeatureFlags , Names , Stack , Token , ValidationError } from '../../core' ;
7
7
import * as cxapi from '../../cx-api' ;
8
8
9
9
/**
@@ -34,20 +34,20 @@ export class SqsSubscription implements sns.ITopicSubscription {
34
34
// Create subscription under *consuming* construct to make sure it ends up
35
35
// in the correct stack in cases of cross-stack subscriptions.
36
36
if ( ! Construct . isConstruct ( this . queue ) ) {
37
- throw new Error ( 'The supplied Queue object must be an instance of Construct' ) ;
37
+ throw new ValidationError ( 'The supplied Queue object must be an instance of Construct' , topic ) ;
38
38
}
39
39
const snsServicePrincipal = new iam . ServicePrincipal ( 'sns.amazonaws.com' ) ;
40
40
41
41
// if the queue is encrypted by AWS managed KMS key (alias/aws/sqs),
42
42
// throw error message
43
43
if ( this . queue . encryptionType === sqs . QueueEncryption . KMS_MANAGED ) {
44
- throw new Error ( 'SQS queue encrypted by AWS managed KMS key cannot be used as SNS subscription' ) ;
44
+ throw new ValidationError ( 'SQS queue encrypted by AWS managed KMS key cannot be used as SNS subscription' , topic ) ;
45
45
}
46
46
47
47
// if the dead-letter queue is encrypted by AWS managed KMS key (alias/aws/sqs),
48
48
// throw error message
49
49
if ( this . props . deadLetterQueue && this . props . deadLetterQueue . encryptionType === sqs . QueueEncryption . KMS_MANAGED ) {
50
- throw new Error ( 'SQS queue encrypted by AWS managed KMS key cannot be used as dead-letter queue' ) ;
50
+ throw new ValidationError ( 'SQS queue encrypted by AWS managed KMS key cannot be used as dead-letter queue' , topic ) ;
51
51
}
52
52
53
53
// add a statement to the queue resource policy which allows this topic
0 commit comments