aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template/error.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-05-03 12:54:52 +0200
committerJosé Valim <jose.valim@gmail.com>2010-05-03 12:59:48 +0200
commit8ae9b05fa0ca579ecabcd563e6ba75ea0f44f074 (patch)
treedc8f820019681e695f5e4c26f49095a530e4f82d /actionpack/lib/action_view/template/error.rb
parent0e00f428a816cd24ca645794385fd7b71dbfed73 (diff)
downloadrails-8ae9b05fa0ca579ecabcd563e6ba75ea0f44f074.tar.gz
rails-8ae9b05fa0ca579ecabcd563e6ba75ea0f44f074.tar.bz2
rails-8ae9b05fa0ca579ecabcd563e6ba75ea0f44f074.zip
Make backtrace_cleaner work as expected. Prior to this patch, the Full Trace rarely showed the full trace. Also, increase performance considerably.
Diffstat (limited to 'actionpack/lib/action_view/template/error.rb')
-rw-r--r--actionpack/lib/action_view/template/error.rb32
1 files changed, 6 insertions, 26 deletions
diff --git a/actionpack/lib/action_view/template/error.rb b/actionpack/lib/action_view/template/error.rb
index 5222ffa89c..a947d746e3 100644
--- a/actionpack/lib/action_view/template/error.rb
+++ b/actionpack/lib/action_view/template/error.rb
@@ -21,17 +21,18 @@ module ActionView
super("Missing #{template_type} #{path} with #{details.inspect} in view paths #{display_paths}")
end
end
+
class Template
# The Template::Error exception is raised when the compilation of the template fails. This exception then gathers a
# bunch of intimate details and uses it to report a very precise exception message.
class Error < ActionViewError #:nodoc:
SOURCE_CODE_RADIUS = 3
- attr_reader :original_exception
+ attr_reader :original_exception, :backtrace
def initialize(template, assigns, original_exception)
@template, @assigns, @original_exception = template, assigns.dup, original_exception
- @backtrace = compute_backtrace
+ @backtrace = original_exception.backtrace
end
def file_name
@@ -42,14 +43,6 @@ module ActionView
ActiveSupport::Deprecation.silence { original_exception.message }
end
- def clean_backtrace
- if defined?(Rails) && Rails.respond_to?(:backtrace_cleaner)
- Rails.backtrace_cleaner.clean(original_exception.backtrace)
- else
- original_exception.backtrace
- end
- end
-
def sub_template_message
if @sub_templates
"Trace of template inclusion: " +
@@ -87,29 +80,16 @@ module ActionView
@line_number ||=
if file_name
regexp = /#{Regexp.escape File.basename(file_name)}:(\d+)/
-
- $1 if message =~ regexp or clean_backtrace.find { |line| line =~ regexp }
+ $1 if message =~ regexp || backtrace.find { |line| line =~ regexp }
end
end
def to_s
- "\n#{self.class} (#{message}) #{source_location}:\n" +
- "#{source_extract}\n #{clean_backtrace.join("\n ")}\n\n"
- end
-
- # don't do anything nontrivial here. Any raised exception from here becomes fatal
- # (and can't be rescued).
- def backtrace
- @backtrace
+ "\n#{self.class} (#{message}) #{source_location}:\n\n" +
+ "#{source_extract(4)}\n #{backtrace.join("\n ")}\n\n"
end
private
- def compute_backtrace
- [
- "#{source_location.capitalize}\n\n#{source_extract(4)}\n " +
- clean_backtrace.join("\n ")
- ]
- end
def source_location
if line_number