Browse files

Fix failing cascade exception.

  • Loading branch information...
1 parent 0e17cf1 commit 2ab2077235308aaa82dc430f1da8d6519fb7dac0 @josevalim josevalim committed Dec 3, 2011
View
3 actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
@@ -15,14 +15,15 @@ def call(env)
begin
response = @app.call(env)
+ # TODO: Maybe this should be in the router itself
if response[1]['X-Cascade'] == 'pass'
raise ActionController::RoutingError, "No route matches [#{env['REQUEST_METHOD']}] #{env['PATH_INFO'].inspect}"
end
rescue Exception => exception
raise exception if env['action_dispatch.show_exceptions'] == false
end
- response ? response : render_exception(env, exception)
+ exception ? render_exception(env, exception) : response
end
private
View
2 actionpack/lib/action_dispatch/middleware/show_exceptions.rb
@@ -40,7 +40,7 @@ def call(env)
raise exception if env['action_dispatch.show_exceptions'] == false
end
- response ? response : render_exception_with_failsafe(env, exception)
+ response || render_exception_with_failsafe(env, exception)
end
private
View
9 actionpack/test/dispatch/debug_exceptions_test.rb
@@ -11,6 +11,8 @@ def call(env)
env['action_dispatch.show_detailed_exceptions'] = @detailed
req = ActionDispatch::Request.new(env)
case req.path
+ when "/pass"
+ [404, { "X-Cascade" => "pass" }, []]
when "/not_found"
raise ActionController::UnknownAction
when "/runtime_error"
@@ -46,6 +48,13 @@ def call(env)
end
end
+ test 'raise an exception on cascade pass' do
+ @app = ProductionApp
+ assert_raise ActionController::RoutingError do
+ get "/pass", {}, {'action_dispatch.show_exceptions' => true}
+ end
+ end
+
test "rescue with diagnostics message" do
@app = DevelopmentApp

0 comments on commit 2ab2077

Please sign in to comment.