diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-12-02 12:55:08 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-12-02 12:55:08 -0200 |
commit | 9fd6011f40a0fb7792867ef1a48ac0dbbb2ffee0 (patch) | |
tree | 78b631fb0e057b7a315cadbec187b790000ad31c /actionpack/lib/action_dispatch/middleware/debug_exceptions.rb | |
parent | 47af13cfb562a8048c68ffe59687eacb9d5a9ad9 (diff) | |
parent | 083f657c0f1990e980d33f89f44d8943a9270475 (diff) | |
download | rails-9fd6011f40a0fb7792867ef1a48ac0dbbb2ffee0.tar.gz rails-9fd6011f40a0fb7792867ef1a48ac0dbbb2ffee0.tar.bz2 rails-9fd6011f40a0fb7792867ef1a48ac0dbbb2ffee0.zip |
Merge pull request #17873 from kirs/refactor-debug-erb
Refactor debug view
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/debug_exceptions.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/debug_exceptions.rb | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb index c1562fcc0d..9f27187aa7 100644 --- a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb @@ -2,12 +2,40 @@ require 'action_dispatch/http/request' require 'action_dispatch/middleware/exception_wrapper' require 'action_dispatch/routing/inspector' +require 'pp' + module ActionDispatch # This middleware is responsible for logging exceptions and # showing a debugging page in case the request is local. class DebugExceptions RESCUES_TEMPLATE_PATH = File.expand_path('../templates', __FILE__) + class DebugView < ActionView::Base + def debug_params(params) + clean_params = params.clone + clean_params.delete("action") + clean_params.delete("controller") + + if clean_params.empty? + 'None' + else + PP.pp(clean_params, "", 200) + end + end + + def debug_headers(headers) + if headers.present? + headers.inspect.gsub(',', ",\n") + else + 'None' + end + end + + def debug_hash(object) + object.to_hash.sort_by { |k, _| k.to_s }.map { |k, v| "#{k}: #{v.inspect rescue $!.message}" }.join("\n") + end + end + def initialize(app, routes_app = nil) @app = app @routes_app = routes_app @@ -46,7 +74,7 @@ module ActionDispatch source_to_show_id = source_to_show[:id] end - template = ActionView::Base.new([RESCUES_TEMPLATE_PATH], + template = DebugView.new([RESCUES_TEMPLATE_PATH], request: request, exception: wrapper.exception, traces: traces, |