Refactor to handle the X-Cascade without having to raise an exception

This commit is contained in:
Krekoten' Marjan 2010-10-19 00:05:22 +03:00 committed by Jeremy Kemper
parent 3e2465521b
commit 366e7854ac
1 changed files with 11 additions and 11 deletions

View File

@ -43,20 +43,20 @@ module ActionDispatch
end
def call(env)
status, headers, body = @app.call(env)
begin
status, headers, body = @app.call(env)
exception = nil
# Only this middleware cares about RoutingError. So, let's just raise
# it here.
# TODO: refactor this middleware to handle the X-Cascade scenario without
# having to raise an exception.
if headers['X-Cascade'] == 'pass'
raise ActionController::RoutingError, "No route matches #{env['PATH_INFO'].inspect}"
# Only this middleware cares about RoutingError. So, let's just raise
# it here.
if headers['X-Cascade'] == 'pass'
exception = ActionController::RoutingError.new("No route matches #{env['PATH_INFO'].inspect}")
end
rescue Exception => exception
end
[status, headers, body]
rescue Exception => exception
raise exception if env['action_dispatch.show_exceptions'] == false
render_exception(env, exception)
exception ? render_exception(env, exception) : [status, headers, body]
end
private