Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 52aeb8d2e7
Fetching contributors…

Cannot retrieve contributors at this time

27 lines (24 sloc) 0.701 kB
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
Jump to Line
Something went wrong with that request. Please try again.