Skip to content

No dump of the entire template when a syntax error is encountered: #54410

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

Merged
merged 1 commit into from
Feb 2, 2025

Conversation

Edouard-chin
Copy link
Member

Motivation / Background

No dump of the entire template when a syntax error is encountered:

  • When rendering a erb template with a syntax error, we were previously dumping the entire content of the template file into the debug view, un-itended, un-highlighted and all in red. It really doesn't help and distract a user from seeing the actually useful stack trace.

    The only time where this could be useful is when we render a inline template (that could be dynamicallt generated), and therefore it kinda make sense to dump it's content.

    This commit prevents dumping the content of the template if rendered from a file, and will keep dumping inline content.

Before

image

After

image

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@MatheusRich
Copy link
Contributor

This looks so much better!

@MatheusRich MatheusRich added the ready PRs ready to merge label Jan 31, 2025
- When rendering a erb template with a syntax error, we were
  previously dumping the entire content of the template file into the
  debug view, un-itended, un-highlighted and all in red. It really
  doesn't help and distract a user from seeing the actually useful
  stack trace.

  The only time where this could be useful is when we render a inline
  template (that could be dynamicallt generated), and therefore
  it kinda make sense to dump it's content.

  This commit prevents dumping the content of the template if rendered
  from a file, and will keep dumping inline content.
@byroot byroot merged commit 728a2d5 into rails:main Feb 2, 2025
3 checks passed
@Edouard-chin Edouard-chin deleted the ec-syntax-error branch February 2, 2025 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants