Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3970 from lest/backtrace-when-silenced

log exception backtrace when all backtrace lines silenced
  • Loading branch information...
commit 5dc4868962b77858ce477e17dbaf07bb4155d38d 2 parents ab802e7 + 081431f
@josevalim josevalim authored
View
5 actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
@@ -59,10 +59,13 @@ def log_error(env, wrapper)
exception = wrapper.exception
+ trace = wrapper.application_trace
+ trace = wrapper.framework_trace if trace.empty?
+
ActiveSupport::Deprecation.silence do
message = "\n#{exception.class} (#{exception.message}):\n"
message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
- message << " " << wrapper.application_trace.join("\n ")
+ message << " " << trace.join("\n ")
logger.fatal("#{message}\n\n")
end
end
View
13 actionpack/test/dispatch/debug_exceptions_test.rb
@@ -122,4 +122,17 @@ def call(env)
get "/", {}, {'action_dispatch.show_exceptions' => true, 'action_dispatch.backtrace_cleaner' => cleaner}
assert_match(/passed backtrace cleaner/, body)
end
+
+ test 'logs exception backtrace when all lines silenced' do
+ output = StringIO.new
+ backtrace_cleaner = ActiveSupport::BacktraceCleaner.new
+ backtrace_cleaner.add_silencer { true }
+
+ env = {'action_dispatch.show_exceptions' => true,
+ 'action_dispatch.logger' => Logger.new(output),
+ 'action_dispatch.backtrace_cleaner' => backtrace_cleaner}
+
+ get "/", {}, env
+ assert_operator (output.rewind && output.read).lines.count, :>, 10
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.