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 19, 2021
1 parent 2217158 commit cfd828e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/plugins/aws/lib/monitorStack.js
Expand Up @@ -106,6 +106,13 @@ module.exports = {
if (!this.options.verbose) legacy.consoleLog('');
legacy.log('Operation failed!');
legacy.log(`View the full error output: ${stackUrl}`);

const decoratedErrorMessage = `${stackLatestError.ResourceStatus}: ${
stackLatestError.LogicalResourceId
} ${style.aside(`(${stackLatestError.ResourceType})`)}\n${
stackLatestError.ResourceStatusReason
}\n\n${style.aside(`View the full error: ${style.link(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 cfd828e

Please sign in to comment.