aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-05-09 12:52:26 +0300
committerJosé Valim <jose.valim@gmail.com>2010-05-09 12:52:30 +0300
commit6c2d974e152850b533dafc6654d0df7bddfbd4bf (patch)
tree0cd81cf50494f971c4822fb3a606fee7d34ea898 /actionpack
parent2969543cef63de08a8da369b83007d17e8941b6e (diff)
downloadrails-6c2d974e152850b533dafc6654d0df7bddfbd4bf.tar.gz
rails-6c2d974e152850b533dafc6654d0df7bddfbd4bf.tar.bz2
rails-6c2d974e152850b533dafc6654d0df7bddfbd4bf.zip
Use annoted source code in Template:Error to avoid special cases in the show exceptions middleware.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/middleware/show_exceptions.rb12
-rw-r--r--actionpack/lib/action_view/template/error.rb5
-rw-r--r--actionpack/test/template/render_test.rb1
3 files changed, 7 insertions, 11 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
index 12a93d6a24..2dd2ec9fe9 100644
--- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
+++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
@@ -133,14 +133,10 @@ module ActionDispatch
return unless logger
ActiveSupport::Deprecation.silence do
- if ActionView::Template::Error === exception
- logger.fatal(exception.to_s)
- else
- logger.fatal(
- "\n#{exception.class} (#{exception.message}):\n " +
- clean_backtrace(exception).join("\n ") + "\n\n"
- )
- end
+ message = "\n#{exception.class} (#{exception.message}):\n"
+ message << exception.annoted_source_code if exception.respond_to?(:annoted_source_code)
+ message << exception.backtrace.join("\n ")
+ logger.fatal("#{message}\n\n")
end
end
diff --git a/actionpack/lib/action_view/template/error.rb b/actionpack/lib/action_view/template/error.rb
index a947d746e3..6866eabf77 100644
--- a/actionpack/lib/action_view/template/error.rb
+++ b/actionpack/lib/action_view/template/error.rb
@@ -84,9 +84,8 @@ module ActionView
end
end
- def to_s
- "\n#{self.class} (#{message}) #{source_location}:\n\n" +
- "#{source_extract(4)}\n #{backtrace.join("\n ")}\n\n"
+ def annoted_source_code
+ source_extract(4)
end
private
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb
index c9a50da418..d0212024ae 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionpack/test/template/render_test.rb
@@ -111,6 +111,7 @@ module RenderTestCases
assert_match %r!method.*doesnt_exist!, e.message
assert_equal "", e.sub_template_message
assert_equal "1", e.line_number
+ assert_equal "1: <%= doesnt_exist %>", e.annoted_source_code.strip
assert_equal File.expand_path("#{FIXTURE_LOAD_PATH}/test/_raise.html.erb"), e.file_name
end