You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Issue
Closes#32569
### Description of changes
Throw typed errors everywhere.
This introduced a new error type `ExecutionError` that is meant for failures from external scripts or code.
### Describe any new or updated permissions being added
n/a
### Description of how you validated changes
Existing tests. Exemptions granted as this is a refactor of existing code.
### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy file name to clipboardExpand all lines: packages/aws-cdk-lib/core/lib/arn.ts
+9-8Lines changed: 9 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
import{Fn}from'./cfn-fn';
2
+
import{UnscopedValidationError}from'./errors';
2
3
import{Stack}from'./stack';
3
4
import{Token}from'./token';
4
5
import{filterUndefined}from'./util';
@@ -141,7 +142,7 @@ export class Arn {
141
142
142
143
// Catch both 'null' and 'undefined'
143
144
if(partition==null||region==null||account==null){
144
-
thrownewError(`Arn.format: partition (${partition}), region (${region}), and account (${account}) must all be passed if stack is not passed.`);
145
+
thrownewUnscopedValidationError(`Arn.format: partition (${partition}), region (${region}), and account (${account}) must all be passed if stack is not passed.`);
@@ -172,21 +173,21 @@ export class AssetStaging extends Construct {
172
173
};
173
174
174
175
if(!fs.existsSync(this.sourcePath)){
175
-
thrownewError(`Cannot find asset at ${this.sourcePath}`);
176
+
thrownewValidationError(`Cannot find asset at ${this.sourcePath}`,this);
176
177
}
177
178
178
179
this.sourceStats=fs.statSync(this.sourcePath);
179
180
180
181
constoutdir=Stage.of(this)?.assetOutdir;
181
182
if(!outdir){
182
-
thrownewError('unable to determine cloud assembly asset output directory. Assets must be defined indirectly within a "Stage" or an "App" scope');
183
+
thrownewValidationError('unable to determine cloud assembly asset output directory. Assets must be defined indirectly within a "Stage" or an "App" scope',this);
183
184
}
184
185
this.assetOutdir=outdir;
185
186
186
187
// Determine the hash type based on the props as props.assetHashType is
thrownewError(`Cannot specify \`${assetHashType}\` for \`assetHashType\` when \`assetHash\` is specified. Use \`CUSTOM\` or leave \`undefined\`.`);
545
+
thrownewValidationError(`Cannot specify \`${assetHashType}\` for \`assetHashType\` when \`assetHash\` is specified. Use \`CUSTOM\` or leave \`undefined\`.`,scope);
// auto-discover means that if there is an archive file, we take it as the
638
639
// bundle, otherwise, we will archive here.
@@ -646,7 +647,7 @@ function determineBundledAsset(bundleDir: string, outputType: BundlingOutput): B
646
647
caseBundlingOutput.ARCHIVED:
647
648
caseBundlingOutput.SINGLE_FILE:
648
649
if(!archiveFile){
649
-
thrownewError('Bundling output directory is expected to include only a single file when `output` is set to `ARCHIVED` or `SINGLE_FILE`');
650
+
thrownewValidationError('Bundling output directory is expected to include only a single file when `output` is set to `ARCHIVED` or `SINGLE_FILE`',scope);
0 commit comments