diff options
| author | Vijay Dev <vijaydev.cse@gmail.com> | 2015-08-24 06:05:07 +0000 | 
|---|---|---|
| committer | Vijay Dev <vijaydev.cse@gmail.com> | 2015-08-24 06:05:07 +0000 | 
| commit | 4f252cddc1ee4e28c633a2250335b2fac4d31108 (patch) | |
| tree | 776177555c7039204e23c9c1b7d33b700d366ca3 /actionpack/lib/action_dispatch/middleware/show_exceptions.rb | |
| parent | bc36ffeec05692777f4ece09978a321feed2d818 (diff) | |
| parent | 06818cb9a8cee8c95eaebdd1418e6fcb0da9382e (diff) | |
| download | rails-4f252cddc1ee4e28c633a2250335b2fac4d31108.tar.gz rails-4f252cddc1ee4e28c633a2250335b2fac4d31108.tar.bz2 rails-4f252cddc1ee4e28c633a2250335b2fac4d31108.zip | |
Merge branch 'master' of github.com:rails/rails
Conflicts:
	guides/source/security.md
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/show_exceptions.rb')
| -rw-r--r-- | actionpack/lib/action_dispatch/middleware/show_exceptions.rb | 20 | 
1 files changed, 11 insertions, 9 deletions
| diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb index f0779279c1..64695f9738 100644 --- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb @@ -27,24 +27,26 @@ module ActionDispatch      end      def call(env) +      request = ActionDispatch::Request.new env        @app.call(env)      rescue Exception => exception -      if env['action_dispatch.show_exceptions'] == false -        raise exception +      if request.show_exceptions? +        render_exception(request, exception)        else -        render_exception(env, exception) +        raise exception        end      end      private -    def render_exception(env, exception) -      wrapper = ExceptionWrapper.new(env, exception) +    def render_exception(request, exception) +      backtrace_cleaner = request.get_header 'action_dispatch.backtrace_cleaner' +      wrapper = ExceptionWrapper.new(backtrace_cleaner, exception)        status  = wrapper.status_code -      env["action_dispatch.exception"] = wrapper.exception -      env["action_dispatch.original_path"] = env["PATH_INFO"] -      env["PATH_INFO"] = "/#{status}" -      response = @exceptions_app.call(env) +      request.set_header "action_dispatch.exception", wrapper.exception +      request.set_header "action_dispatch.original_path", request.path_info +      request.path_info = "/#{status}" +      response = @exceptions_app.call(request.env)        response[1]['X-Cascade'] == 'pass' ? pass_response(status) : response      rescue Exception => failsafe_error        $stderr.puts "Error during failsafe response: #{failsafe_error}\n  #{failsafe_error.backtrace * "\n  "}" | 
