diff options
author | Krekoten' Marjan <krekoten@gmail.com> | 2010-10-19 00:05:22 +0300 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2011-01-09 16:08:54 -0800 |
commit | 366e7854ac41699217e8cad1a336ab845c781359 (patch) | |
tree | dc0a8e2fa1f78a6b8d04d578921bb32b7072a44a /actionpack/lib/action_dispatch/middleware | |
parent | 3e2465521bdcbae978b445987af9b5fc68c43a3d (diff) | |
download | rails-366e7854ac41699217e8cad1a336ab845c781359.tar.gz rails-366e7854ac41699217e8cad1a336ab845c781359.tar.bz2 rails-366e7854ac41699217e8cad1a336ab845c781359.zip |
Refactor to handle the X-Cascade without having to raise an exception
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/show_exceptions.rb | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb index 71e736ce9f..936fd548b9 100644 --- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb @@ -43,20 +43,20 @@ module ActionDispatch end def call(env) - status, headers, body = @app.call(env) - - # 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}" + begin + status, headers, body = @app.call(env) + exception = nil + + # 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 |