diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2012-12-31 14:36:23 -0500 |
---|---|---|
committer | Guillermo Iguaran <guilleiguaran@gmail.com> | 2012-12-31 16:46:37 -0500 |
commit | 5a1b885dd620e6ab465c0f64b7cd0f025a46fb37 (patch) | |
tree | 00e54e1e794cf7440b3f74a04d39b8380b886c63 /actionpack/lib/action_dispatch | |
parent | 9b79bb469b02c9c51440960cfc33bd928c9fbd1d (diff) | |
download | rails-5a1b885dd620e6ab465c0f64b7cd0f025a46fb37.tar.gz rails-5a1b885dd620e6ab465c0f64b7cd0f025a46fb37.tar.bz2 rails-5a1b885dd620e6ab465c0f64b7cd0f025a46fb37.zip |
Add style to AV::Template::Error exception page
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/exception_wrapper.rb | 3 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.erb | 53 |
2 files changed, 42 insertions, 14 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb b/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb index d1cadbd082..ee69c8b49d 100644 --- a/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb +++ b/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb @@ -57,7 +57,7 @@ module ActionDispatch end def source_extract - if trace = application_trace.first + if application_trace && trace = application_trace.first file, line, _ = trace.split(":") @file = file @line_number = line.to_i @@ -92,6 +92,7 @@ module ActionDispatch end def source_fragment(path, line) + return unless Rails.respond_to?(:root) && Rails.root full_path = Rails.root.join(path) if File.exists?(full_path) File.open(full_path, "r") do |file| diff --git a/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.erb b/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.erb index a1b377f68c..01faf5a475 100644 --- a/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.erb +++ b/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.erb @@ -1,17 +1,44 @@ -<h1> - <%=h @exception.original_exception.class.to_s %> in - <%=h @request.parameters["controller"].capitalize if @request.parameters["controller"]%>#<%=h @request.parameters["action"] %> -</h1> +<% @source_extract = @exception.source_extract(0, :html) %> +<header> + <h1> + <%=h @exception.original_exception.class.to_s %> in + <%=h @request.parameters["controller"].capitalize if @request.parameters["controller"]%>#<%=h @request.parameters["action"] %> + </h1> +</header> -<p> - Showing <i><%=h @exception.file_name %></i> where line <b>#<%=h @exception.line_number %></b> raised: - <pre><code><%=h @exception.message %></code></pre> -</p> +<div id="container"> + <p> + Showing <i><%=h @exception.file_name %></i> where line <b>#<%=h @exception.line_number %></b> raised: + <pre><code><%=h @exception.message %></code></pre> + </p> -<p>Extracted source (around line <b>#<%=h @exception.line_number %></b>): -<pre><code><%=h @exception.source_extract %></code></pre></p> + <div class="source"> + <div class="info"> + <p>Extracted source (around line <strong>#<%=h @exception.line_number %></strong>): + </div> + <div class="data"> + <table cellpadding="0" cellspacing="0" class="lines"> + <tr> + <td> + <pre class="line_numbers"> + <% @source_extract.keys.each do |line_number| %> +<span><%= line_number -%></span> + <% end %> + </pre> + </td> +<td width="100%"> +<pre> +<% @source_extract.each do |line, source| -%><div class="line<%= " active" if line == @exception.line_number -%>"><%= source -%></div><% end -%> +</pre> +</td> + </tr> + </table> +</div> +</div> -<p><%=h @exception.sub_template_message %></p> + <p><%=h @exception.sub_template_message %></p> -<%= render template: "rescues/_trace" %> -<%= render template: "rescues/_request_and_response" %> + <%= render template: "rescues/_trace" %> + <%= render template: "rescues/_request_and_response" %> + </div> +</div> |