Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/aws-cdk-lib/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const enableNoThrowDefaultErrorIn = [
'aws-elasticloadbalancingv2-actions',
'aws-elasticloadbalancingv2-targets',
'aws-fsx',
'aws-kinesis',
'aws-kinesisfirehose',
'aws-lambda',
'aws-logs',
Expand Down
6 changes: 3 additions & 3 deletions packages/aws-cdk-lib/aws-kinesis/lib/resource-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CfnResourcePolicy } from './kinesis.generated';
import { IStream } from './stream';
import { IStreamConsumer } from './stream-consumer';
import { PolicyDocument } from '../../aws-iam';
import { Resource } from '../../core';
import { Resource, ValidationError } from '../../core';
import { addConstructMetadata } from '../../core/lib/metadata-resource';

/**
Expand Down Expand Up @@ -62,10 +62,10 @@ export class ResourcePolicy extends Resource {
addConstructMetadata(this, props);

if (props.stream && props.streamConsumer) {
throw new Error('Only one of stream or streamConsumer can be set');
throw new ValidationError('Only one of stream or streamConsumer can be set', this);
}
if (props.stream === undefined && props.streamConsumer === undefined) {
throw new Error('One of stream or streamConsumer must be set');
throw new ValidationError('One of stream or streamConsumer must be set', this);
}

this.document = props.policyDocument ?? this.document;
Expand Down
10 changes: 5 additions & 5 deletions packages/aws-cdk-lib/aws-kinesis/lib/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ResourcePolicy } from './resource-policy';
import * as cloudwatch from '../../aws-cloudwatch';
import * as iam from '../../aws-iam';
import * as kms from '../../aws-kms';
import { ArnFormat, Aws, CfnCondition, Duration, Fn, IResolvable, IResource, RemovalPolicy, Resource, ResourceProps, Stack, Token } from '../../core';
import { ArnFormat, Aws, CfnCondition, Duration, Fn, IResolvable, IResource, RemovalPolicy, Resource, ResourceProps, Stack, Token, ValidationError } from '../../core';
import { addConstructMetadata } from '../../core/lib/metadata-resource';

const READ_OPERATIONS = [
Expand Down Expand Up @@ -841,7 +841,7 @@ export class Stream extends StreamBase {
const streamMode = props.streamMode;

if (streamMode === StreamMode.ON_DEMAND && shardCount !== undefined) {
throw new Error(`streamMode must be set to ${StreamMode.PROVISIONED} (default) when specifying shardCount`);
throw new ValidationError(`streamMode must be set to ${StreamMode.PROVISIONED} (default) when specifying shardCount`, this);
}
if ((streamMode === StreamMode.PROVISIONED || streamMode === undefined) && shardCount === undefined) {
shardCount = 1;
Expand All @@ -850,7 +850,7 @@ export class Stream extends StreamBase {
const retentionPeriodHours = props.retentionPeriod?.toHours() ?? 24;
if (!Token.isUnresolved(retentionPeriodHours)) {
if (retentionPeriodHours < 24 || retentionPeriodHours > 8760) {
throw new Error(`retentionPeriod must be between 24 and 8760 hours. Received ${retentionPeriodHours}`);
throw new ValidationError(`retentionPeriod must be between 24 and 8760 hours. Received ${retentionPeriodHours}`, this);
}
}

Expand Down Expand Up @@ -915,7 +915,7 @@ export class Stream extends StreamBase {

// if encryption key is set, encryption must be set to KMS.
if (encryptionType !== StreamEncryption.KMS && props.encryptionKey) {
throw new Error(`encryptionKey is specified, so 'encryption' must be set to KMS (value: ${encryptionType})`);
throw new ValidationError(`encryptionKey is specified, so 'encryption' must be set to KMS (value: ${encryptionType})`, this);
}

if (encryptionType === StreamEncryption.UNENCRYPTED) {
Expand All @@ -939,7 +939,7 @@ export class Stream extends StreamBase {
return { encryptionKey, streamEncryption };
}

throw new Error(`Unexpected 'encryptionType': ${encryptionType}`);
throw new ValidationError(`Unexpected 'encryptionType': ${encryptionType}`, this);
}
}

Expand Down
Loading