@@ -3,7 +3,7 @@ import { SubscriptionProps } from './subscription';
33import * as iam from '../../aws-iam' ;
44import * as sns from '../../aws-sns' ;
55import * as sqs from '../../aws-sqs' ;
6- import { ArnFormat , FeatureFlags , Names , Stack , Token } from '../../core' ;
6+ import { ArnFormat , FeatureFlags , Names , Stack , Token , ValidationError } from '../../core' ;
77import * as cxapi from '../../cx-api' ;
88
99/**
@@ -34,20 +34,20 @@ export class SqsSubscription implements sns.ITopicSubscription {
3434 // Create subscription under *consuming* construct to make sure it ends up
3535 // in the correct stack in cases of cross-stack subscriptions.
3636 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 ) ;
3838 }
3939 const snsServicePrincipal = new iam . ServicePrincipal ( 'sns.amazonaws.com' ) ;
4040
4141 // if the queue is encrypted by AWS managed KMS key (alias/aws/sqs),
4242 // throw error message
4343 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 ) ;
4545 }
4646
4747 // if the dead-letter queue is encrypted by AWS managed KMS key (alias/aws/sqs),
4848 // throw error message
4949 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 ) ;
5151 }
5252
5353 // add a statement to the queue resource policy which allows this topic
0 commit comments