From f03f846729c7ebb6e1664b5a9229445da5516d06 Mon Sep 17 00:00:00 2001 From: Piotr Grzesik Date: Mon, 18 Oct 2021 19:22:06 +0200 Subject: [PATCH] refactor(CLI): Enhanced modern error reporting for CloudFormation --- lib/plugins/aws/lib/monitorStack.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/plugins/aws/lib/monitorStack.js b/lib/plugins/aws/lib/monitorStack.js index 9127f7859cc2..b6c05447ae24 100644 --- a/lib/plugins/aws/lib/monitorStack.js +++ b/lib/plugins/aws/lib/monitorStack.js @@ -105,7 +105,14 @@ module.exports = { // empty console.log for a prettier output if (!this.options.verbose) legacy.consoleLog(''); legacy.log('Operation failed!'); - legacy.log(`View the full error output: ${stackUrl}`); + legacy.log(`View the full error output: ${style.link(stackUrl)}`); + + const decoratedErrorMessage = `${stackLatestError.ResourceStatus}: ${ + stackLatestError.LogicalResourceId + } ${style.aside(`(${stackLatestError.ResourceType})`)}\n${ + stackLatestError.ResourceStatusReason + }\n\n${style.aside(`View the full error: ${stackUrl}`)}`; + let errorMessage = 'An error occurred: '; errorMessage += `${stackLatestError.LogicalResourceId} - `; errorMessage += `${ @@ -133,7 +140,9 @@ module.exports = { }` ); })(); - throw new ServerlessError(errorMessage, errorCode); + throw new ServerlessError(errorMessage, errorCode, { + decoratedMessage: decoratedErrorMessage, + }); } }, (e) => {