Parse App errors from CloudExecutables that use sub-shell #32997
Open
Description
Errors thrown by CDK Apps are just printed to stdout/stderr by the subprocess. we should intercept, capture and re-throw the error. Instead this should be thrown by toolkit.synth
directly.
We need to pass a magic env variable CDK_SERIALIZE_ERRORS
to the cdk app. When this variable is set, then we add the following snippet:
process.on('uncaughtException', function(err) {
// do magic here, e.g.
console.error('Caught exception: ' + err);
});
This needs to somehow announce to the parent process that the app is no sending a JSON serialized error through the channel.
In the CLI/Toolkit we need to detect this and NOT print regularly. Instead we deserialize the error, recreate it to a proper Node exception and re throw it (toolkit). In the CLI we can also add some nice formatting on the error.