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 development mode exceptions with alert dialog for JavaScript requests #27381

wants to merge 1 commit into from


Copy link

@mrhead mrhead commented Dec 16, 2016


Previously when an exception occurred for a SJR request, then no error was shown. You had to check the server log, or request information via browser's web development tools.

This PRs shows backend exceptions for SJR requests immediately in the alert dialog.





Other Information

  • I've tested it with Google Chrome, Safari and Firefox. It works great with all of them.
  • I've tested it with jquery_ujs and rails_ujs.
Copy link

@rails-bot rails-bot commented Dec 16, 2016

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @matthewd (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

Copy link

@carlosramireziii carlosramireziii commented Jan 12, 2017

@mrhead This seems like an excellent change to make SJR easier to use and debug.

I have been maintaining a gem called BetterSJR which aims to do just that. If this change does not make it in to Rails Core, I'd welcome a pull request to the gem to incorporate this functionality there.


Copy link

@gmcgibbon gmcgibbon left a comment

Still relevant in Rails 6 (bd139a5). I like the idea behind this change but I think it could use a refactor. If we're going to change this behaviour, it should be displaying errors in the console and not a modal.

@@ -93,7 +93,10 @@ def render_for_browser_request(request, wrapper)
template = create_template(request, wrapper)
file = "rescues/#{wrapper.rescue_template}"

if request.xhr?
if request.format == "text/javascript"

This comment has been minimized.


gmcgibbon Jul 24, 2018

You can do request.format.js?. I'm kind of disappointed, I don't see a request.js? 😦

@@ -0,0 +1 @@
alert("<%= j yield %>");

This comment has been minimized.


gmcgibbon Jul 24, 2018

Modals are intrusive and annoying by design. If I was debugging a tricky error I wouldn't want it to keep popping up in a modal. The console would be a much more fitting place for error. Would you consider changing this to console.error or throw new Error?

Copy link

@rails-bot rails-bot bot commented Dec 18, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@rails-bot rails-bot added the stale label Dec 18, 2019
@rails-bot rails-bot closed this Dec 25, 2019
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.

None yet

6 participants
You can’t perform that action at this time.