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 @@ -62,6 +62,7 @@ const enableNoThrowDefaultErrorIn = [
'aws-logs',
'aws-rds',
'aws-s3',
'aws-ses',
'aws-sns',
'aws-sqs',
'aws-ssm',
Expand Down
5 changes: 3 additions & 2 deletions packages/aws-cdk-lib/aws-ses-actions/lib/add-header.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as ses from '../../aws-ses';
import { UnscopedValidationError } from '../../core';

/**
* Construction properties for a add header action.
Expand Down Expand Up @@ -28,11 +29,11 @@ export class AddHeader implements ses.IReceiptRuleAction {
constructor(props: AddHeaderProps) {
if (!/^[a-zA-Z0-9-]{1,50}$/.test(props.name)) {
// eslint-disable-next-line max-len
throw new Error('Header `name` must be between 1 and 50 characters, inclusive, and consist of alphanumeric (a-z, A-Z, 0-9) characters and dashes only.');
throw new UnscopedValidationError('Header `name` must be between 1 and 50 characters, inclusive, and consist of alphanumeric (a-z, A-Z, 0-9) characters and dashes only.');
}

if (!/^[^\n\r]{0,2047}$/.test(props.value)) {
throw new Error('Header `value` must be less than 2048 characters, and must not contain newline characters ("\r" or "\n").');
throw new UnscopedValidationError('Header `value` must be less than 2048 characters, and must not contain newline characters ("\r" or "\n").');
}

this.name = props.name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as events from '../../aws-events';
import * as iam from '../../aws-iam';
import * as firehose from '../../aws-kinesisfirehose';
import * as sns from '../../aws-sns';
import { Aws, IResource, Resource, Stack } from '../../core';
import { Aws, IResource, Resource, Stack, ValidationError } from '../../core';
import { addConstructMetadata } from '../../core/lib/metadata-resource';

/**
Expand Down Expand Up @@ -296,7 +296,7 @@ export class ConfigurationSetEventDestination extends Resource implements IConfi
resourceName: 'default',
})
) {
throw new Error(`Only the default bus can be used as an event destination. Got ${props.destination.bus.eventBusArn}`);
throw new ValidationError(`Only the default bus can be used as an event destination. Got ${props.destination.bus.eventBusArn}`, this);
}

let firehoseDeliveryStreamIamRoleArn = '';
Expand Down
8 changes: 4 additions & 4 deletions packages/aws-cdk-lib/aws-ses/lib/configuration-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ConfigurationSetEventDestination, ConfigurationSetEventDestinationOptio
import { IDedicatedIpPool } from './dedicated-ip-pool';
import { undefinedIfNoKeys } from './private/utils';
import { CfnConfigurationSet } from './ses.generated';
import { Duration, IResource, Resource, Token } from '../../core';
import { Duration, IResource, Resource, Token, ValidationError } from '../../core';
import { addConstructMetadata, MethodMetadata } from '../../core/lib/metadata-resource';

/**
Expand Down Expand Up @@ -179,14 +179,14 @@ export class ConfigurationSet extends Resource implements IConfigurationSet {
addConstructMetadata(this, props);

if (props.disableSuppressionList && props.suppressionReasons) {
throw new Error('When disableSuppressionList is true, suppressionReasons must not be specified.');
throw new ValidationError('When disableSuppressionList is true, suppressionReasons must not be specified.', this);
}
if (props.maxDeliveryDuration && !Token.isUnresolved(props.maxDeliveryDuration)) {
if (props.maxDeliveryDuration.toMilliseconds() < Duration.minutes(5).toMilliseconds()) {
throw new Error(`The maximum delivery duration must be greater than or equal to 5 minutes (300_000 milliseconds), got: ${props.maxDeliveryDuration.toMilliseconds()} milliseconds.`);
throw new ValidationError(`The maximum delivery duration must be greater than or equal to 5 minutes (300_000 milliseconds), got: ${props.maxDeliveryDuration.toMilliseconds()} milliseconds.`, this);
}
if (props.maxDeliveryDuration.toSeconds() > Duration.hours(14).toSeconds()) {
throw new Error(`The maximum delivery duration must be less than or equal to 14 hours (50400 seconds), got: ${props.maxDeliveryDuration.toSeconds()} seconds.`);
throw new ValidationError(`The maximum delivery duration must be less than or equal to 14 hours (50400 seconds), got: ${props.maxDeliveryDuration.toSeconds()} seconds.`, this);
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk-lib/aws-ses/lib/dedicated-ip-pool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Construct } from 'constructs';
import { CfnDedicatedIpPool } from './ses.generated';
import { IResource, Resource } from '../../core';
import { IResource, Resource, ValidationError } from '../../core';
import { addConstructMetadata } from '../../core/lib/metadata-resource';

/**
Expand Down Expand Up @@ -82,7 +82,7 @@ export class DedicatedIpPool extends Resource implements IDedicatedIpPool {
addConstructMetadata(this, props);

if (props.dedicatedIpPoolName && !/^[a-z0-9_-]{0,64}$/.test(props.dedicatedIpPoolName)) {
throw new Error(`Invalid dedicatedIpPoolName "${props.dedicatedIpPoolName}". The name must only include lowercase letters, numbers, underscores, hyphens, and must not exceed 64 characters.`);
throw new ValidationError(`Invalid dedicatedIpPoolName "${props.dedicatedIpPoolName}". The name must only include lowercase letters, numbers, underscores, hyphens, and must not exceed 64 characters.`, this);
}

const pool = new CfnDedicatedIpPool(this, 'Resource', {
Expand Down