mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove Rescue middleware that was never used by Rails.
This commit is contained in:
parent
f32247cb3e
commit
58f69ba085
3 changed files with 1 additions and 43 deletions
|
@ -60,7 +60,6 @@ module ActionDispatch
|
|||
autoload :PublicExceptions
|
||||
autoload :Reloader
|
||||
autoload :RemoteIp
|
||||
autoload :Rescue
|
||||
autoload :ShowExceptions
|
||||
autoload :Static
|
||||
end
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
module ActionDispatch
|
||||
class Rescue
|
||||
def initialize(app, rescuers = {}, &block)
|
||||
@app, @rescuers = app, {}
|
||||
rescuers.each { |exception, rescuer| rescue_from(exception, rescuer) }
|
||||
instance_eval(&block) if block_given?
|
||||
end
|
||||
|
||||
def call(env)
|
||||
@app.call(env)
|
||||
rescue Exception => exception
|
||||
if rescuer = @rescuers[exception.class.name]
|
||||
env['action_dispatch.rescue.exception'] = exception
|
||||
rescuer.call(env)
|
||||
else
|
||||
raise exception
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
def rescue_from(exception, rescuer)
|
||||
exception = exception.class.name if exception.is_a?(Exception)
|
||||
@rescuers[exception.to_s] = rescuer
|
||||
end
|
||||
end
|
||||
end
|
|
@ -338,23 +338,8 @@ class RescueTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
end
|
||||
|
||||
test 'rescue routing exceptions' do
|
||||
raiser = proc { |env| raise ActionController::RoutingError, "Did not handle the request" }
|
||||
@app = ActionDispatch::Rescue.new(raiser) do
|
||||
rescue_from ActionController::RoutingError, lambda { |env| [200, {"Content-Type" => "text/html"}, ["Gotcha!"]] }
|
||||
end
|
||||
|
||||
get '/b00m'
|
||||
assert_equal "Gotcha!", response.body
|
||||
end
|
||||
|
||||
test 'unrescued exception' do
|
||||
raiser = proc { |env| raise ActionController::RoutingError, "Did not handle the request" }
|
||||
@app = ActionDispatch::Rescue.new(raiser)
|
||||
assert_raise(ActionController::RoutingError) { get '/b00m' }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def with_test_routing
|
||||
with_routing do |set|
|
||||
set.draw do
|
||||
|
|
Loading…
Reference in a new issue