diff --git a/packages/@aws-cdk/cdk/lib/construct.ts b/packages/@aws-cdk/cdk/lib/construct.ts index 3a94d1eabe3d3..a998a6a285ab0 100644 --- a/packages/@aws-cdk/cdk/lib/construct.ts +++ b/packages/@aws-cdk/cdk/lib/construct.ts @@ -48,10 +48,11 @@ export class ConstructNode { const validate = options.skipValidation === undefined ? true : !options.skipValidation; if (validate) { const errors = this.validate(root); - if (errors.length > 0) { - const errorList = errors.map(e => `[${e.source.node.path}] ${e.message}`).join('\n '); - throw new Error(`Validation failed with the following errors:\n ${errorList}`); - } + // Turn the errors into metadata errors, so they will prevent deploying but will not + // prevent CDK from executing again. + errors.forEach(e => { + e.source.node.addError(e.message); + }); } // synthesize (leaves first) diff --git a/packages/@aws-cdk/cdk/test/test.app.ts b/packages/@aws-cdk/cdk/test/test.app.ts index 43ecd055a6104..1e9b508e744d4 100644 --- a/packages/@aws-cdk/cdk/test/test.app.ts +++ b/packages/@aws-cdk/cdk/test/test.app.ts @@ -156,7 +156,11 @@ export = { new Child(parent, 'C1'); new Child(parent, 'C2'); - test.throws(() => app.synth(), /Validation failed with the following errors/); + const assembly = app.synth(); + test.deepEqual(assembly.getStack('Parent').messages.filter(m => m.level === cxapi.SynthesisMessageLevel.ERROR).map(m => m.entry.data), [ + 'Error from C1', + 'Error from C2', + ]); test.done(); },