Skip to content

Commit

Permalink
refactor(CLI): Enhanced modern error reporting for CloudFormation
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed Oct 18, 2021
1 parent 866bf2d commit f03f846
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/plugins/aws/lib/monitorStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 += `${
Expand Down Expand Up @@ -133,7 +140,9 @@ module.exports = {
}`
);
})();
throw new ServerlessError(errorMessage, errorCode);
throw new ServerlessError(errorMessage, errorCode, {
decoratedMessage: decoratedErrorMessage,
});
}
},
(e) => {
Expand Down

0 comments on commit f03f846

Please sign in to comment.