Changeset 2624
- Timestamp:
- 10/15/05 19:05:15 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/rescues/diagnostics.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/rescues/template_error.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_view/base.rb (modified) (1 diff)
- trunk/actionpack/lib/action_view/template_error.rb (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r2612 r2624 1 1 *SVN* 2 3 * Clean up error pages by providing better backtraces [Nicholas Seckar] 2 4 3 5 * Raise an exception if an attempt is made to insert more session data into the ActiveRecordStore data column than the column can hold. #2234. [justin@textdrive.com] trunk/actionpack/lib/action_controller/templates/rescues/diagnostics.rhtml
r1048 r2624 1 <%2 clean_backtrace = @exception.backtrace.collect { |line| Object.const_defined?(:RAILS_ROOT) ? line.gsub(RAILS_ROOT, "") : line }3 app_trace = clean_backtrace.reject { |line| line =~ /(vendor|dispatch|ruby)/ }4 framework_trace = clean_backtrace - app_trace5 %>6 7 1 <h1> 8 2 <%=h @exception.class.to_s %> in 9 3 <%=h (@request.parameters["controller"] || "<controller not set>").capitalize %>#<%=h @request.parameters["action"] || "<action not set>" %> 10 4 </h1> 11 <pre><%=h Object.const_defined?(:RAILS_ROOT) ? @exception.message.gsub(RAILS_ROOT, "") : @exception.message %></pre>5 <pre><%=h @exception.clean_message %></pre> 12 6 13 <% unless app_trace.empty? %><pre><code><%=h app_trace.join("\n") %></code></pre><% end %> 14 15 <% unless framework_trace.empty? %> 16 <a href="#" onclick="document.getElementById('framework_trace').style.display='block'; return false;">Show framework trace</a> 17 <pre id="framework_trace" style="display:none"><code><%=h framework_trace.join("\n") %></code></pre> 18 <% end %> 7 <%= render_file(@rescues_path + "/_trace.rhtml", false) %> 19 8 20 9 <%= render_file(@rescues_path + "/_request_and_response.rhtml", false) %> trunk/actionpack/lib/action_controller/templates/rescues/template_error.rhtml
r1173 r2624 14 14 <p><%=h @exception.sub_template_message %></p> 15 15 16 <a href="#" onclick="document.getElementById('framework_trace').style.display='block'">Show template trace</a> 17 <pre id="framework_trace" style="display:none"><code><%=h @exception.original_exception.backtrace.collect { |line| Object.const_defined?(:RAILS_ROOT) ? line.gsub(RAILS_ROOT, "") : line }.join("\n") %></code></pre> 16 <% @real_exception = @exception 17 @exception = @exception.original_exception || @exception %> 18 <%= render_file(@rescues_path + "/_trace.rhtml", false) %> 19 <% @exception = @real_exception %> 18 20 19 21 <%= render_file(@rescues_path + "/_request_and_response.rhtml", false) %> trunk/actionpack/lib/action_view/base.rb
r2571 r2624 406 406 begin 407 407 unless file_name.blank? 408 CompiledTemplates.module_eval(render_source, File.expand_path(file_name), -line_offset)408 CompiledTemplates.module_eval(render_source, file_name, -line_offset) 409 409 else 410 410 CompiledTemplates.module_eval(render_source, 'compiled-template', -line_offset) trunk/actionpack/lib/action_view/template_error.rb
r2058 r2624 10 10 @base_path, @assigns, @source, @original_exception = 11 11 base_path, assigns, source, original_exception 12 @file_name = File.expand_pathfile_name12 @file_name = file_name 13 13 end 14 14 … … 47 47 48 48 def line_number 49 if @file_name50 regexp = /#{Regexp.escape @file_name}(?:\(.*?\))?:(\d+)/ # A regexp to match a line number in our file51 [@original_exception.message, @original_exception. backtrace].flatten.each do |line|49 if file_name 50 regexp = /#{Regexp.escape file_name}:(\d+)\s*$/ 51 [@original_exception.message, @original_exception.clean_backtrace].flatten.each do |line| 52 52 return $1.to_i if regexp =~ line 53 53 end … … 57 57 58 58 def file_name 59 strip_base_path(@file_name) 59 stripped = strip_base_path(@file_name) 60 stripped[0] == ?/ ? stripped[1..-1] : stripped 60 61 end 61 62 … … 63 64 "\n\n#{self.class} (#{message}) on line ##{line_number} of #{file_name}:\n" + 64 65 source_extract + "\n " + 65 clean_backtrace(original_exception).join("\n ") +66 original_exception.clean_backtrace.join("\n ") + 66 67 "\n\n" 67 68 end … … 70 71 [ 71 72 "On line ##{line_number} of #{file_name}\n\n#{source_extract(4)}\n " + 72 clean_backtrace(original_exception).join("\n ")73 original_exception.clean_backtrace.join("\n ") 73 74 ] 74 75 end … … 79 80 file_name.gsub(@base_path, "") 80 81 end 81 82 if defined?(RAILS_ROOT)83 RailsRootRegexp = %r((#{Regexp.escape RAILS_ROOT}|#{Regexp.escape File.expand_path(RAILS_ROOT)})/(.*)?)84 else85 RailsRootRegexp = /^()(.*)$/86 end87 88 def clean_backtrace(exception)89 exception.backtrace.collect do |line|90 line.gsub %r{^(\s*)(/[-\w\d\./]+)} do91 leading, path = $1, $292 path = $2 if RailsRootRegexp =~ path93 leading + path94 end95 end96 end97 82 end 98 83 end 84 85 Exception::TraceSubstitutions << [/:in\s+`_run_(html|xml).*'\s*$/, ''] if defined?(Exception::TraceSubstitutions)