Sha256: dae87d57765846d5e1919571c71df9b1dca3a1e49fdd4c02bf4ab7a304967627

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

module YogiBerra
  class ExceptionMiddleware
    def initialize(app)
      @app = app
    end

    def call(env)
      begin
        response = @app.call(env)
      rescue Exception => raised
        path_parameters = env['action_controller.request.path_parameters'] || {}
        query_hash      = env['rack.request.query_hash'] || {}
        environment = {
          :session => env['rack.session'],
          :params => path_parameters.merge(query_hash),
          :user_agent => env['HTTP_USER_AGENT'],
          :server_name => env['SERVER_NAME'],
          :server_port => env['SERVER_PORT'],
          :server_address => env['SERVER_ADDR'],
          :controller => env['action_controller.instance'],
          :remote_address => env['REMOTE_ADDR']
        }

        YogiBerra.exceptionize(raised, environment)
        raise raised
      end

      if env['rack.exception']
        YogiBerra.exceptionize(raised, environment)
      end
      response
    end

    def each(&block)
      @response.each(&block)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
yogi_berra-0.2.1 lib/yogi_berra/exception_middleware.rb
yogi_berra-0.2.0 lib/yogi_berra/exception_middleware.rb
yogi_berra-0.1.7 lib/yogi_berra/exception_middleware.rb
yogi_berra-0.1.6 lib/yogi_berra/exception_middleware.rb
yogi_berra-0.1.4 lib/yogi_berra/exception_middleware.rb
yogi_berra-0.1.3 lib/yogi_berra/exception_middleware.rb