Skip to content

Commit fbba9c7

Browse files
authored
chore: throw more descriptive error when failing to create output directory (#18296)
I passed a `--output` to the CDK that was `/public/something/or/other`, on a system with no `/public`, and then forgot about it. I was presented with the head-scratch-inducing failure message: ``` ENOENT: no such file or directory, mkdir '/public' Error: ENOENT: no such file or directory, mkdir '/public' ``` This should improve the error so that some reference is made to why the CDK expects or desires this path to exist (and remind me that in fact I told it to go there). ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 13c47bd commit fbba9c7

File tree

1 file changed

+5
-1
lines changed
  • packages/aws-cdk/lib/api/cxapp

1 file changed

+5
-1
lines changed

packages/aws-cdk/lib/api/cxapp/exec.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ export async function execProgram(aws: SdkProvider, config: Configuration): Prom
6868
if (!outdir) {
6969
throw new Error('unexpected: --output is required');
7070
}
71-
await fs.mkdirp(outdir);
71+
try {
72+
await fs.mkdirp(outdir);
73+
} catch (error) {
74+
throw new Error(`Could not create output directory ${outdir} (${error.message})`);
75+
}
7276

7377
debug('outdir:', outdir);
7478
env[cxapi.OUTDIR_ENV] = outdir;

0 commit comments

Comments
 (0)