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 @@ -37,6 +37,7 @@ const enableNoThrowDefaultErrorIn = [
'aws-cognito',
'aws-cloudfront',
'aws-cloudfront-origins',
'aws-cloudtrail',
'aws-elasticloadbalancing',
'aws-elasticloadbalancingv2',
'aws-elasticloadbalancingv2-actions',
Expand Down
8 changes: 4 additions & 4 deletions packages/aws-cdk-lib/aws-cloudtrail/lib/cloudtrail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as lambda from '../../aws-lambda';
import * as logs from '../../aws-logs';
import * as s3 from '../../aws-s3';
import * as sns from '../../aws-sns';
import { Resource, Stack } from '../../core';
import { Resource, Stack, ValidationError } from '../../core';
import { addConstructMetadata, MethodMetadata } from '../../core/lib/metadata-resource';

/**
Expand Down Expand Up @@ -322,7 +322,7 @@ export class Trail extends Resource {
this.node.addValidation({ validate: () => this.validateEventSelectors() });

if (props.kmsKey && props.encryptionKey) {
throw new Error('Both kmsKey and encryptionKey must not be specified. Use only encryptionKey');
throw new ValidationError('Both kmsKey and encryptionKey must not be specified. Use only encryptionKey', this);
}

if (props.insightTypes) {
Expand Down Expand Up @@ -384,11 +384,11 @@ export class Trail extends Resource {
@MethodMetadata()
public addEventSelector(dataResourceType: DataResourceType, dataResourceValues: string[], options: AddEventSelectorOptions = {}) {
if (dataResourceValues.length > 250) {
throw new Error('A maximum of 250 data elements can be in one event selector');
throw new ValidationError('A maximum of 250 data elements can be in one event selector', this);
}

if (this.eventSelectors.length > 5) {
throw new Error('A maximum of 5 event selectors are supported per trail.');
throw new ValidationError('A maximum of 5 event selectors are supported per trail.', this);
}

let includeAllManagementEvents;
Expand Down