Sha256: 84a39b1f56735c10bf1f94260cbccba66b41b60f6f518ed04db23f8eb2f8af8c

Contents?: true

Size: 701 Bytes

Versions: 225

Compression:

Stored size: 701 Bytes

Contents

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

Version data entries

225 entries across 186 versions & 19 rubygems

Version Path
actionpack-3.2.22.5 lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.22.4 lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.22.3 lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.22.2 lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.22.1 lib/action_dispatch/middleware/rescue.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.22 lib/action_dispatch/middleware/rescue.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.12/lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.21 lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.20 lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.19 lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.18 lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.17 lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.16 lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.15 lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.15.rc3 lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.15.rc2 lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.15.rc1 lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.14 lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.14.rc2 lib/action_dispatch/middleware/rescue.rb