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 @@ -50,6 +50,7 @@ const enableNoThrowDefaultErrorIn = [
'aws-docdb',
'aws-dynamodb',
'aws-ecr',
'aws-ecr-assets',
'aws-efs',
'aws-elasticloadbalancing',
'aws-elasticloadbalancingv2',
Expand Down
10 changes: 5 additions & 5 deletions packages/aws-cdk-lib/aws-ecr-assets/lib/image-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as path from 'path';
import { Construct } from 'constructs';
import { FingerprintOptions, FollowMode, IAsset } from '../../assets';
import * as ecr from '../../aws-ecr';
import { Annotations, AssetStaging, FeatureFlags, FileFingerprintOptions, IgnoreMode, Stack, SymlinkFollowMode, Token, Stage, CfnResource } from '../../core';
import { Annotations, AssetStaging, FeatureFlags, FileFingerprintOptions, IgnoreMode, Stack, SymlinkFollowMode, Token, Stage, CfnResource, ValidationError, UnscopedValidationError } from '../../core';
import * as cxapi from '../../cx-api';

/**
Expand Down Expand Up @@ -435,14 +435,14 @@ export class DockerImageAsset extends Construct implements IAsset {
// resolve full path
const dir = path.resolve(props.directory);
if (!fs.existsSync(dir)) {
throw new Error(`Cannot find image directory at ${dir}`);
throw new ValidationError(`Cannot find image directory at ${dir}`, this);
}

// validate the docker file exists
this.dockerfilePath = props.file || 'Dockerfile';
const file = path.join(dir, this.dockerfilePath);
if (!fs.existsSync(file)) {
throw new Error(`Cannot find file at ${file}`);
throw new ValidationError(`Cannot find file at ${file}`, this);
}

const defaultIgnoreMode = FeatureFlags.of(this).isEnabled(cxapi.DOCKER_IGNORE_SUPPORT)
Expand Down Expand Up @@ -582,7 +582,7 @@ export class DockerImageAsset extends Construct implements IAsset {
function validateProps(props: DockerImageAssetProps) {
for (const [key, value] of Object.entries(props)) {
if (Token.isUnresolved(value)) {
throw new Error(`Cannot use Token as value of '${key}': this value is used before deployment starts`);
throw new UnscopedValidationError(`Cannot use Token as value of '${key}': this value is used before deployment starts`);
}
}

Expand All @@ -593,7 +593,7 @@ function validateProps(props: DockerImageAssetProps) {
function validateBuildProps(buildPropName: string, buildProps?: { [key: string]: string }) {
for (const [key, value] of Object.entries(buildProps || {})) {
if (Token.isUnresolved(key) || Token.isUnresolved(value)) {
throw new Error(`Cannot use tokens in keys or values of "${buildPropName}" since they are needed before deployment`);
throw new UnscopedValidationError(`Cannot use tokens in keys or values of "${buildPropName}" since they are needed before deployment`);
}
}
}
Expand Down
Loading