# File lib/rack/contrib/route_exceptions.rb, line 24 def call(env, try_again = true) returned = @app.call(env) rescue Exception => exception raise(exception) unless try_again ROUTES.each do |klass, to| next unless klass === exception return route(to, env, returned, exception) end raise(exception) end
# File lib/rack/contrib/route_exceptions.rb, line 37 def route(to, env, returned, exception) env.merge!( PATH_INFO => env['PATH_INFO'], EXCEPTION => exception, RETURNED => returned ) env['PATH_INFO'] = to call(env, try_again = false) end
# File lib/rack/contrib/route_exceptions.rb, line 20 def initialize(app) @app = app end
# File lib/rack/contrib/route_exceptions.rb, line 12 def route(exception, to) ROUTES.delete_if{|k,v| k == exception } ROUTES << [exception, to] end