Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced CloudFormation error reporting with modern logs #10112

Merged
merged 2 commits into from Oct 19, 2021

Conversation

pgrzesik
Copy link
Contributor

@pgrzesik pgrzesik commented Oct 18, 2021

Addresses: #9860

exampleoutput

@codecov
Copy link

codecov bot commented Oct 18, 2021

Codecov Report

Merging #10112 (3785bc6) into master (ff4072b) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #10112   +/-   ##
=======================================
  Coverage   85.26%   85.26%           
=======================================
  Files         334      334           
  Lines       13638    13640    +2     
=======================================
+ Hits        11628    11630    +2     
  Misses       2010     2010           
Impacted Files Coverage Δ
lib/utils/tokenize-exception.js 100.00% <ø> (ø)
lib/cli/handle-error.js 84.84% <100.00%> (ø)
lib/plugins/aws/lib/monitorStack.js 96.29% <100.00%> (+0.04%) ⬆️
lib/serverless-error.js 100.00% <100.00%> (ø)
lib/plugins/aws/package/index.js 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff4072b...3785bc6. Read the comment docs.

@pgrzesik pgrzesik requested a review from medikoo October 18, 2021 15:38
@@ -133,7 +140,7 @@ module.exports = {
}`
);
})();
throw new ServerlessError(errorMessage, errorCode);
throw new ServerlessError(errorMessage, errorCode, decoratedErrorMessage);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As passing inline optional arguments one by one, seems an anti-pattern, I would either support it as an option so:

new ServerlessError(errorMessage, errorCode, { decoratedErrorMessage })

or simply decorate error on spot:

throw Object.assign(new ServerlessError(errorMessage, errorCode), { decoratedErrorMessage) })

stackLatestError.LogicalResourceId
} ${style.aside(`(${stackLatestError.ResourceType})`)}\n${
stackLatestError.ResourceStatusReason
}\n\n${style.aside(`View the full error: ${stackUrl}`)}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll be nice to wrap url with style.link

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see legacy.log decorated with style.link instead of decorated log :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, that's embarassing

I've fixed it

@pgrzesik pgrzesik force-pushed the enhanced-cloudformation-error-reporting branch from 6f06c72 to f03f846 Compare October 18, 2021 17:23
@pgrzesik pgrzesik requested a review from medikoo October 18, 2021 17:32
@pgrzesik pgrzesik force-pushed the enhanced-cloudformation-error-reporting branch from f03f846 to 3785bc6 Compare October 19, 2021 11:28
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍

@pgrzesik pgrzesik merged commit cfd828e into master Oct 19, 2021
@pgrzesik pgrzesik deleted the enhanced-cloudformation-error-reporting branch October 19, 2021 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants