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
challah-0.9.1.beta vendor/bundle/gems/actionpack-3.2.11/lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.11 lib/action_dispatch/middleware/rescue.rb
actionpack-3.1.10 lib/action_dispatch/middleware/rescue.rb
actionpack-3.0.19 lib/action_dispatch/middleware/rescue.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/middleware/rescue.rb
challah-0.9.0 vendor/bundle/gems/actionpack-3.2.9/lib/action_dispatch/middleware/rescue.rb
actionpack-3.2.10 lib/action_dispatch/middleware/rescue.rb
actionpack-3.1.9 lib/action_dispatch/middleware/rescue.rb
actionpack-3.0.18 lib/action_dispatch/middleware/rescue.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.3/vendor/bundle/gems/actionpack-3.2.9/lib/action_dispatch/middleware/rescue.rb
jquery_regex-0.0.3 vendor/bundle/gems/actionpack-3.2.9/lib/action_dispatch/middleware/rescue.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.1/vendor/bundle/gems/actionpack-3.2.9/lib/action_dispatch/middleware/rescue.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.2/vendor/bundle/gems/actionpack-3.2.9/lib/action_dispatch/middleware/rescue.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.3/vendor/bundle/gems/jquery_regex-0.0.1/vendor/bundle/gems/actionpack-3.2.9/lib/action_dispatch/middleware/rescue.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.2/vendor/bundle/gems/jquery_regex-0.0.1/vendor/bundle/gems/actionpack-3.2.9/lib/action_dispatch/middleware/rescue.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.3/vendor/bundle/gems/jquery_regex-0.0.2/vendor/bundle/gems/actionpack-3.2.9/lib/action_dispatch/middleware/rescue.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.3/vendor/bundle/gems/jquery_regex-0.0.2/vendor/bundle/gems/jquery_regex-0.0.1/vendor/bundle/gems/actionpack-3.2.9/lib/action_dispatch/middleware/rescue.rb
jquery_regex-0.0.1 vendor/bundle/gems/actionpack-3.2.9/lib/action_dispatch/middleware/rescue.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/actionpack-3.2.7/lib/action_dispatch/middleware/rescue.rb
challah-rolls-0.2.0 vendor/bundle/gems/actionpack-3.2.8/lib/action_dispatch/middleware/rescue.rb