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
merged 1 commit into from May 13, 2020

Conversation

RobinDaugherty
Copy link
Member

@RobinDaugherty 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
@RobinDaugherty RobinDaugherty deleted the feature/action-view-template-error-backtrace branch May 13, 2020 17:40
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.

Can't see errors in templates binding_of_caller hides stack trace for ActionView::Template::Error
1 participant