Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -41,6 +41,7 @@ const enableNoThrowDefaultErrorIn = [
'aws-cloudtrail',
'aws-cloudwatch',
'aws-cloudwatch-actions',
'aws-codecommit',
'aws-ecr',
'aws-elasticloadbalancing',
'aws-elasticloadbalancingv2',
Expand Down
9 changes: 5 additions & 4 deletions packages/aws-cdk-lib/aws-codecommit/lib/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as path from 'path';
import { Construct } from 'constructs';
import { CfnRepository } from './codecommit.generated';
import * as assets from '../../aws-s3-assets';
import { UnscopedValidationError, ValidationError } from '../../core';

/**
* Represents the structure to pass into the underlying CfnRepository class.
Expand All @@ -28,7 +29,7 @@ export abstract class Code {

const statResult = fs.statSync(resolvedPath);
if (!statResult || !statResult.isDirectory()) {
throw new Error(`'${directoryPath}' needs to be a path to a directory (resolved to: '${resolvedPath }')`);
throw new UnscopedValidationError(`'${directoryPath}' needs to be a path to a directory (resolved to: '${resolvedPath }')`);
}

return new PathResolvedCode(resolvedPath, branch);
Expand All @@ -44,7 +45,7 @@ export abstract class Code {

const statResult = fs.statSync(resolvedPath);
if (!statResult || !statResult.isFile()) {
throw new Error(`'${filePath}' needs to be a path to a ZIP file (resolved to: '${resolvedPath }')`);
throw new UnscopedValidationError(`'${filePath}' needs to be a path to a ZIP file (resolved to: '${resolvedPath }')`);
}

return new PathResolvedCode(resolvedPath, branch);
Expand Down Expand Up @@ -86,9 +87,9 @@ class AssetCode extends Code {
super();
}

public bind(_scope: Construct): CodeConfig {
public bind(scope: Construct): CodeConfig {
if (!this.asset.isZipArchive) {
throw new Error('Asset must be a .zip file or a directory (resolved to: ' + this.asset.assetPath + ' )');
throw new ValidationError('Asset must be a .zip file or a directory (resolved to: ' + this.asset.assetPath + ' )', scope);
}

return {
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk-lib/aws-codecommit/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as notifications from '../../aws-codestarnotifications';
import * as events from '../../aws-events';
import * as iam from '../../aws-iam';
import * as kms from '../../aws-kms';
import { ArnFormat, IResource, Lazy, Resource, Stack } from '../../core';
import { ArnFormat, IResource, Lazy, Resource, Stack, ValidationError } from '../../core';
import { addConstructMetadata, MethodMetadata } from '../../core/lib/metadata-resource';

/**
Expand Down Expand Up @@ -605,7 +605,7 @@ export class Repository extends RepositoryBase {
}

if (this.triggers.find(prop => prop.name === name)) {
throw new Error(`Unable to set repository trigger named ${name} because trigger names must be unique`);
throw new ValidationError(`Unable to set repository trigger named ${name} because trigger names must be unique`, this);
}

this.triggers.push({
Expand Down
Loading