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 location of error in ActionView template error #463

merged 1 commit into from May 13, 2020


Copy link

RobinDaugherty commented May 13, 2020

Fixes #461, fixes #462.

Previous to Rails 5.1, when an error was raised in a template, it included the location within the template in the backtrace. As of 5.1, the exception was replaced with an ActionView::Template::Error which provides file_name and line_number but does not include those in the backtrace. It does provide a cause which contains the real error and correct backtrace, but as of Better Errors 2.7.0 (#459) we stopped showing only the "cause" of an error. (And in the future we want to add navigation within the chain of error causes, see #464.)

Showing the broken state, with a backtrace that does not include the template.

SyntaxError and Haml::SyntaxError were handled specially by Better Errors, finding the filename and line number within the exception message and synthesizing a backtrace item based on those. The workaround for ActionView::Template::Error looks exactly like those.

The result is that the topmost backtrace item will be the location of the error within the template.

The same error showing a backtrace including the template

@RobinDaugherty RobinDaugherty merged commit 7c063ad into master May 13, 2020
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
continuous-integration/travis-ci/push The Travis CI build passed
@RobinDaugherty RobinDaugherty deleted the feature/action-view-template-error-backtrace branch May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

1 participant
You can’t perform that action at this time.