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 diagnostics in text format for xhr request #14745

Merged
merged 1 commit into from
Apr 15, 2014

Conversation

razum2um
Copy link
Contributor

When non ActionController errors (e.g. ActiveRecord::NotFound) is raised in controller's
detailed exception (xhr.responseText) is rendered like this:

<header>
  <h1>
    RuntimeError
  </h1>
</header>

<div id="container">
  <h2>puke!</h2>

Rails.root: unset

Application Trace
/Users/razum2um/Code/rails/actionpack/test/dispatch/debug_exceptions_test.rb:60:in `call'
/Users/razum2um/Code/rails/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'

This fixes it by using standard .text template
Initial idea in #11960

rafaelfranca added a commit that referenced this pull request Apr 15, 2014
Display diagnostics in text format for xhr request
@rafaelfranca rafaelfranca merged commit 3fce111 into rails:master Apr 15, 2014
tijmenb added a commit to tijmenb/rails that referenced this pull request Nov 3, 2015
When a request is made with AJAX and an error occurs, Rails will render
a text-template for the exception instead of the HTML error page
(rails#11960).

The `.text.erb` variant of the `_source` template is currently missing,
causing HTML to be rendered in the response. This commit adds the text
template.

To keep the page scannable we only only show the first three source
extracts.

Related to rails#14745.

Before:

```
~/testing-exceptions  ᐅ curl 'http://localhost:3000/' -H
'X-Requested-With: XMLHttpRequest'
RuntimeError in PostsController#index

    <div class="source " id="frame-source-0">
      <div class="info">
        Extracted source (around line <strong>rails#3</strong>):
      </div>
      <div class="data">
        <table cellpadding="0" cellspacing="0" class="lines">
          <tr>
```

After:

```
~/testing-exceptions  ᐅ curl 'http://localhost:3000/' -H
'X-Requested-With: XMLHttpRequest'
RuntimeError in PostsController#index

Extracted source (around line rails#3):

*3     raise
```
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.

2 participants