aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-12-01 21:15:42 +0100
committerJosé Valim <jose.valim@gmail.com>2011-12-01 21:15:42 +0100
commitf9edc079e030a5d2b0f21b80d6382caf10751057 (patch)
tree650ea960c7c340eca3b2cc77b6e67ad030866114 /actionpack/lib/action_dispatch
parent750bb5c865ac9234da91ec451eec7d9de55b8f9b (diff)
downloadrails-f9edc079e030a5d2b0f21b80d6382caf10751057.tar.gz
rails-f9edc079e030a5d2b0f21b80d6382caf10751057.tar.bz2
rails-f9edc079e030a5d2b0f21b80d6382caf10751057.zip
Split and improve show and debug exceptions middlewares.
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/middleware/show_exceptions.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
index 346770acb7..c801bcf2ef 100644
--- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
+++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
@@ -3,8 +3,8 @@ require 'action_dispatch/middleware/exception_wrapper'
require 'active_support/deprecation'
module ActionDispatch
- # This middleware rescues any exception returned by the application and renders
- # nice exception pages if it's being rescued locally.
+ # This middleware rescues any exception returned by the application
+ # and wraps them in a format for the end user.
class ShowExceptions
RESCUES_TEMPLATE_PATH = File.join(File.dirname(__FILE__), 'templates')
@@ -40,11 +40,18 @@ module ActionDispatch
raise exception if env['action_dispatch.show_exceptions'] == false
end
- response ? response : render_exception(env, exception)
+ response ? response : render_exception_with_failsafe(env, exception)
end
private
+ def render_exception_with_failsafe(env, exception)
+ render_exception(env, exception)
+ rescue Exception => failsafe_error
+ $stderr.puts "Error during failsafe response: #{failsafe_error}\n #{failsafe_error.backtrace * "\n "}"
+ FAILSAFE_RESPONSE
+ end
+
def render_exception(env, exception)
wrapper = ExceptionWrapper.new(env, exception)
@@ -59,13 +66,6 @@ module ActionDispatch
else
render(status, '')
end
- rescue Exception => failsafe_error
- render_failsafe(failsafe_error)
- end
-
- def render_failsafe(failsafe_error)
- $stderr.puts "Error during failsafe response: #{failsafe_error}\n #{failsafe_error.backtrace * "\n "}"
- FAILSAFE_RESPONSE
end
def render(status, body)
@@ -73,7 +73,7 @@ module ActionDispatch
end
# TODO: Make this a middleware initialization parameter once
- # we deprecated the second option
+ # we removed the second option (which is deprecated)
def public_path
defined?(Rails.public_path) ? Rails.public_path : 'public_path'
end