Skip to content

Commit c74614a

Browse files
authored
Merge branch 'main' into automation/spec-update
2 parents 0b4ebbf + ef477dd commit c74614a

File tree

16 files changed

+89
-45
lines changed

16 files changed

+89
-45
lines changed

.github/workflows/issue-sync.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
# Cache node_modules
2121
- name: Cache node_modules
22-
uses: actions/cache@v3
22+
uses: actions/cache@v4
2323
id: cache-modules
2424
with:
2525
path: |
@@ -37,7 +37,7 @@ jobs:
3737
3838
# Cache build output
3939
- name: Cache build output
40-
uses: actions/cache@v3
40+
uses: actions/cache@v4
4141
id: cache-build
4242
with:
4343
path: |

packages/@aws-cdk/aws-glue-alpha/.eslintrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,12 @@ baseConfig.parserOptions.project = __dirname + '/tsconfig.json';
44
baseConfig.rules['import/no-extraneous-dependencies'] = ['error', { devDependencies: true, peerDependencies: true } ];
55
baseConfig.rules['import/order'] = 'off';
66
baseConfig.rules['@aws-cdk/invalid-cfn-imports'] = 'off';
7+
baseConfig.rules["@cdklabs/no-throw-default-error"] = ["error"];
8+
baseConfig.overrides.push({
9+
files: ["./test/**"],
10+
rules: {
11+
"@cdklabs/no-throw-default-error": "off",
12+
},
13+
});
714

815
module.exports = baseConfig;

packages/@aws-cdk/aws-glue-alpha/lib/code.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class AssetCode extends Code {
6666
super();
6767

6868
if (fs.lstatSync(this.path).isDirectory()) {
69-
throw new Error(`Code path ${this.path} is a directory. Only files are supported`);
69+
throw new cdk.UnscopedValidationError(`Code path ${this.path} is a directory. Only files are supported`);
7070
}
7171
}
7272

@@ -78,7 +78,7 @@ export class AssetCode extends Code {
7878
...this.options,
7979
});
8080
} else if (cdk.Stack.of(this.asset) !== cdk.Stack.of(scope)) {
81-
throw new Error(`Asset is already associated with another stack '${cdk.Stack.of(this.asset).stackName}'. ` +
81+
throw new cdk.UnscopedValidationError(`Asset is already associated with another stack '${cdk.Stack.of(this.asset).stackName}'. ` +
8282
'Create a new Code instance for every stack.');
8383
}
8484
this.asset.grantRead(grantable);

packages/@aws-cdk/aws-glue-alpha/lib/database.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ArnFormat, IResource, Lazy, Names, Resource, Stack } from 'aws-cdk-lib/core';
1+
import { ArnFormat, IResource, Lazy, Names, Resource, Stack, UnscopedValidationError } from 'aws-cdk-lib/core';
22
import { Construct } from 'constructs';
33
import { CfnDatabase } from 'aws-cdk-lib/aws-glue';
44
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';
@@ -152,12 +152,12 @@ export class Database extends Resource implements IDatabase {
152152

153153
function validateLocationUri(locationUri: string): void {
154154
if (locationUri.length < 1 || locationUri.length > 1024) {
155-
throw new Error(`locationUri length must be (inclusively) between 1 and 1024, got ${locationUri.length}`);
155+
throw new UnscopedValidationError(`locationUri length must be (inclusively) between 1 and 1024, got ${locationUri.length}`);
156156
}
157157
}
158158

159159
function validateDescription(description: string): void {
160160
if (description.length > 2048) {
161-
throw new Error(`description length must be less than or equal to 2048, got ${description.length}`);
161+
throw new UnscopedValidationError(`description length must be less than or equal to 2048, got ${description.length}`);
162162
}
163163
}

packages/@aws-cdk/aws-glue-alpha/lib/external-table.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Column } from './schema';
66
import { PartitionIndex, TableBase, TableBaseProps } from './table-base';
77
import { addConstructMetadata, MethodMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';
88
import { propertyInjectable } from 'aws-cdk-lib/core/lib/prop-injectable';
9+
import { ValidationError } from 'aws-cdk-lib';
910

1011
export interface ExternalTableProps extends TableBaseProps {
1112
/**
@@ -90,7 +91,7 @@ export class ExternalTable extends TableBase {
9091
},
9192
parameters: props.storageParameters ? props.storageParameters.reduce((acc, param) => {
9293
if (param.key in acc) {
93-
throw new Error(`Duplicate storage parameter key: ${param.key}`);
94+
throw new ValidationError(`Duplicate storage parameter key: ${param.key}`, this);
9495
}
9596
const key = param.key;
9697
acc[key] = param.value;

packages/@aws-cdk/aws-glue-alpha/lib/jobs/job.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ export abstract class Job extends JobBase {
488488
const reservedArgs = new Set(['--debug', '--mode', '--JOB_NAME']);
489489
Object.keys(defaultArguments).forEach((arg) => {
490490
if (reservedArgs.has(arg)) {
491-
throw new Error(`The ${arg} argument is reserved by Glue. Don't set it`);
491+
throw new cdk.ValidationError(`The ${arg} argument is reserved by Glue. Don't set it`, this);
492492
}
493493
});
494494
}

packages/@aws-cdk/aws-glue-alpha/lib/jobs/ray-job.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Construct } from 'constructs';
55
import { JobType, GlueVersion, WorkerType, Runtime } from '../constants';
66
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';
77
import { propertyInjectable } from 'aws-cdk-lib/core/lib/prop-injectable';
8+
import { ValidationError } from 'aws-cdk-lib/core';
89

910
/**
1011
* Properties for creating a Ray Glue job
@@ -77,7 +78,7 @@ export class RayJob extends Job {
7778
};
7879

7980
if (props.workerType && props.workerType !== WorkerType.Z_2X) {
80-
throw new Error('Ray jobs only support Z.2X worker type');
81+
throw new ValidationError('Ray jobs only support Z.2X worker type', this);
8182
}
8283

8384
const jobResource = new CfnJob(this, 'Resource', {

packages/@aws-cdk/aws-glue-alpha/lib/jobs/scala-spark-etl-job.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Code } from '../code';
55
import { SparkJob, SparkJobProps } from './spark-job';
66
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';
77
import { propertyInjectable } from 'aws-cdk-lib/core/lib/prop-injectable';
8+
import { ValidationError } from 'aws-cdk-lib/core';
89

910
/**
1011
* Properties for creating a Scala Spark ETL job
@@ -89,7 +90,7 @@ export class ScalaSparkEtlJob extends SparkJob {
8990
};
9091

9192
if ((!props.workerType && props.numberOfWorkers !== undefined) || (props.workerType && props.numberOfWorkers === undefined)) {
92-
throw new Error('Both workerType and numberOfWorkers must be set');
93+
throw new ValidationError('Both workerType and numberOfWorkers must be set', this);
9394
}
9495

9596
const jobResource = new CfnJob(this, 'Resource', {

packages/@aws-cdk/aws-glue-alpha/lib/jobs/scala-spark-streaming-job.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Code } from '../code';
55
import { SparkJob, SparkJobProps } from './spark-job';
66
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';
77
import { propertyInjectable } from 'aws-cdk-lib/core/lib/prop-injectable';
8+
import { ValidationError } from 'aws-cdk-lib/core';
89

910
/**
1011
* Properties for creating a Scala Spark ETL job
@@ -89,7 +90,7 @@ export class ScalaSparkStreamingJob extends SparkJob {
8990
};
9091

9192
if ((!props.workerType && props.numberOfWorkers !== undefined) || (props.workerType && props.numberOfWorkers === undefined)) {
92-
throw new Error('Both workerType and numberOfWorkers must be set');
93+
throw new ValidationError('Both workerType and numberOfWorkers must be set', this);
9394
}
9495

9596
const jobResource = new CfnJob(this, 'Resource', {

packages/@aws-cdk/aws-glue-alpha/lib/jobs/spark-job.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';
44
import * as constructs from 'constructs';
55
import { Code } from '../code';
66
import { Job, JobProps } from './job';
7-
import { Token } from 'aws-cdk-lib';
7+
import { Token, UnscopedValidationError } from 'aws-cdk-lib';
88
import { EOL } from 'os';
99

1010
/**
@@ -198,7 +198,7 @@ function validateSparkUiPrefix(prefix?: string): void {
198198
}
199199

200200
if (errors.length > 0) {
201-
throw new Error(`Invalid prefix format (value: ${prefix})${EOL}${errors.join(EOL)}`);
201+
throw new UnscopedValidationError(`Invalid prefix format (value: ${prefix})${EOL}${errors.join(EOL)}`);
202202
}
203203
}
204204

0 commit comments

Comments
 (0)