Skip to content
  • Tijmen Brommet's avatar
    08689a2d
    Add text template for source code · 08689a2d
    Tijmen Brommet authored
    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
    (#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 #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>#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 #3):
    
    *3     raise
    ```
    08689a2d
    Add text template for source code
    Tijmen Brommet authored
    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
    (#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 #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>#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 #3):
    
    *3     raise
    ```
Loading