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

Show a short backtrace on error #384

Merged
merged 1 commit into from
Jul 15, 2024
Merged

Conversation

viraptor
Copy link
Contributor

Currently the errors are not very clear. For example:

StackMaster::TemplateCompiler::TemplateCompilationFailed Failed to
compile elasticsearch_snapshot_bucket.rb
 Caused by: ArgumentError wrong number of arguments (given 2, expected
1)

which doesn't provide the location for the issue in the template.

Instead of the all-or-nothing, if --trace is not provided, show the first 4 lines of the original exception:

 Caused by: ArgumentError wrong number of arguments (given 2, expected
1)
 at
/Users/viraptor/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/sparkle_formation-3.0.40/lib/sparkle_formation/sparkle_attribute/aws.rb:93:in
`_cf_ref'
    ../templates/elasticsearch_snapshot_bucket.rb:62:in `block (3
levels) in compile'
    /Users/viraptor/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/attribute_struct-0.4.4/lib/attribute_struct/attribute_struct.rb:245:in
`instance_exec'
    /Users/viraptor/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/attribute_struct-0.4.4/lib/attribute_struct/attribute_struct.rb:245:in
`method_missing'
 ...
 Use --trace to view backtrace

Currently the errors are not very clear. For example:
```
StackMaster::TemplateCompiler::TemplateCompilationFailed Failed to
compile elasticsearch_snapshot_bucket.rb
 Caused by: ArgumentError wrong number of arguments (given 2, expected
1)
```
which doesn't provide the location for the issue in the template.

Instead of the all-or-nothing, if `--trace` is not provided, show the
first 4 lines of the original exception:

```
 Caused by: ArgumentError wrong number of arguments (given 2, expected
1)
 at
/Users/viraptor/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/sparkle_formation-3.0.40/lib/sparkle_formation/sparkle_attribute/aws.rb:93:in
`_cf_ref'
    ../templates/elasticsearch_snapshot_bucket.rb:62:in `block (3
levels) in compile'
    /Users/viraptor/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/attribute_struct-0.4.4/lib/attribute_struct/attribute_struct.rb:245:in
`instance_exec'
    /Users/viraptor/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/attribute_struct-0.4.4/lib/attribute_struct/attribute_struct.rb:245:in
`method_missing'
 ...
 Use --trace to view backtrace
```
@viraptor viraptor merged commit 143d627 into master Jul 15, 2024
18 checks passed
@viraptor viraptor deleted the viraptor/short-backtrace branch July 15, 2024 02:30
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.

3 participants