class Rack::RouteExceptions
Constants
- EXCEPTION
- PATH_INFO
- ROUTES
Public Class Methods
new(app)
click to toggle source
# File lib/vendor/route_exceptions.rb, line 17 def initialize(app) @app = app end
route(exception, to)
click to toggle source
# File lib/vendor/route_exceptions.rb, line 9 def route(exception, to) ROUTES.delete_if{|k,v| k == exception } ROUTES << [exception, to] end
Also aliased as: []=
Public Instance Methods
call(env, try_again = true)
click to toggle source
# File lib/vendor/route_exceptions.rb, line 21 def call(env, try_again = true) @app.call(env) rescue Exception => exception raise(exception) unless try_again ROUTES.each do |klass, to| next unless klass === exception return route(to, env, exception) end raise(exception) end
route(to, env, exception)
click to toggle source
# File lib/vendor/route_exceptions.rb, line 34 def route(to, env, exception) env.merge!( PATH_INFO => env['PATH_INFO'], EXCEPTION => exception, 'PATH_INFO' => to) call(env, try_again = false) end