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

Display exception messages using simple_format #40567

Merged
merged 1 commit into from
Nov 9, 2020

Conversation

hahmed
Copy link
Contributor

@hahmed hahmed commented Nov 7, 2020

Summary

Currently error messages are displayed all in one line in the error pages, in the rails console/logs they appear nicely on multiple lines, making it easier to grok. With this PR I want to propose that we display error messages in the view on multiple lines making it easier for developers to read the error messages.

These changes were pulled out from #39723

Before:

Screenshot 2020-11-09 at 20 52 47

After:

Screenshot 2020-11-09 at 21 15 49

@rafaelfranca
Copy link
Member

When you are done, can you please post screeshots of before and after?

@hahmed hahmed force-pushed the ha/formatted-error-messages branch from b3b7ba7 to 618d0ae Compare November 9, 2020 21:15
@hahmed hahmed marked this pull request as ready for review November 9, 2020 21:31
@hahmed hahmed marked this pull request as draft November 9, 2020 21:38
@hahmed hahmed force-pushed the ha/formatted-error-messages branch from 618d0ae to 93f0ceb Compare November 9, 2020 21:48
@hahmed
Copy link
Contributor Author

hahmed commented Nov 9, 2020

The "negative" I have found with this is, when we are displaying errors like we have with syntax errors, they are also displayed using simple_format on multiple lines... 😅-- is that an acceptable tradeoff?

Before:

Screenshot 2020-11-09 at 22 07 30

After:

Screenshot 2020-11-09 at 21 42 49

@hahmed hahmed marked this pull request as ready for review November 9, 2020 22:08
@@ -299,7 +300,7 @@ def foo
app("development")
get "/rails/mailers/notifier"
assert_predicate last_response, :not_found?
assert_match "Mailer preview 'notifier' not found", last_response.body
assert_match "Mailer preview 'notifier' not found", h(last_response.body)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately without this change, this test was failing on rails 2.7. If I updated to "Mailer preview 'notifier' not found" this test failed on rails 2.6.5

Example of test failure without this change on 2.7

Failure:
ApplicationTests::MailerPreviewsTest#test_mailer_preview_not_found [test/application/mailer_previews_test.rb:303]:
Expected /Mailer\ preview\ &\#39;notifier&\#39;\ not\ found/ to match # encoding: ASCII-8BIT

Html from mailer (snipped)

 <h1>Unknown action</h1>\n</header>\n<div id=\"container\">\n    <div class=\"exception-message\">\n    <div class=\"message\">Mailer preview 'notifier' not found</div>\n  </div>\n\n</div>\n\n\n</body>\n</html>\n".

@rafaelfranca rafaelfranca merged commit a538e4d into rails:master Nov 9, 2020
rafaelfranca added a commit that referenced this pull request Nov 9, 2020
Display exception messages using simple_format
@hahmed hahmed deleted the ha/formatted-error-messages branch November 10, 2020 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants