mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use annoted source code in Template:Error to avoid special cases in the show exceptions middleware.
This commit is contained in:
parent
2969543cef
commit
6c2d974e15
3 changed files with 7 additions and 11 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue