Skip to content

Commit

Permalink
chore: throw more descriptive error when failing to create output dir…
Browse files Browse the repository at this point in the history
…ectory (aws#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*
  • Loading branch information
adamnovak authored and Stephen Potter committed Apr 27, 2022
1 parent 8534d0f commit 91d3383
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/aws-cdk/lib/api/cxapp/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ export async function execProgram(aws: SdkProvider, config: Configuration): Prom
if (!outdir) {
throw new Error('unexpected: --output is required');
}
await fs.mkdirp(outdir);
try {
await fs.mkdirp(outdir);
} catch (error) {
throw new Error(`Could not create output directory ${outdir} (${error.message})`);
}

debug('outdir:', outdir);
env[cxapi.OUTDIR_ENV] = outdir;
Expand Down

0 comments on commit 91d3383

Please sign in to comment.