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

Print backtrace when compilation fails #251

Merged
merged 1 commit into from
Sep 3, 2018

Conversation

patrobinson
Copy link
Contributor

@patrobinson patrobinson commented Aug 31, 2018

When a template fails to compile it's common to get an error like:

Executing apply on samson-db in us-east-1
StackMaster::TemplateCompiler::TemplateCompilationFailed Failed to compile /Users/matt/Documents/GitHub/our-samson/aws/templates/samson_db.rb.
 Caused by: NameError uninitialized constant #<Class:0x007f850a560748>::Sparkleformation 

Which is quite unhelpful to understand where the error occurs. This PR makes two changes to combat this:

  • When we do catch an exception, print the error and backtrace.

Copy link
Contributor

@petervandoros petervandoros left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@stevehodgkiss
Copy link
Contributor

stevehodgkiss commented Aug 31, 2018

Only catch StandardError. NameError and SyntaxError will throw an exception and not get caught

StandardError is the default for rescue so this isn't changing which errors are being caught (if that was the intention).

@patrobinson
Copy link
Contributor Author

@stevehodgkiss you're right. StandardError will catch NameError but not SyntaxError. I'm not sure what we want to do so I'm just going with printing a backtrace

Copy link
Contributor

@stevehodgkiss stevehodgkiss left a comment

Choose a reason for hiding this comment

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

👍

@patrobinson patrobinson merged commit a308ef8 into master Sep 3, 2018
@patrobinson patrobinson deleted the better-compilation-errors branch September 3, 2018 02:50
patrobinson pushed a commit that referenced this pull request Sep 3, 2018
Improve errors when compilation of a template fails #251
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants