Sha256: a5ae0f8b8045d85a08ccfc6c3479a89e2fa3585e5d7ec394da6b65774901bb99

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

module YogiBerra
  class ExceptionMiddleware
    def initialize(app)
      @app = app
      YogiBerra::Catcher.quick_connection
    end

    def call(env)
      begin
        response = dup._call(env)
        environment = {
          :session => env['rack.session'],
          :params => env['action_controller.request.path_parameters'].merge(env['rack.request.query_hash']),
          :user_agent => env['HTTP_USER_AGENT'],
          :server_name => env['SERVER_NAME'],
          :server_port => env['SERVER_PORT'],
          :server_address => env['SERVER_ADDR'],
          :remote_address => env['REMOTE_ADDR']
        }
      rescue Exception => raised
        YogiBerra.exceptionize(raised, environment, YogiBerra::Catcher.connection)
        raise raised
      end

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

    def _call(env)
      @status, @headers, @response = @app.call(env)
      [@status, @headers, self]
    end

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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yogi_berra-0.0.1 lib/yogi_berra/exception_middleware.rb