Class: LoggingElf::UncaughtExceptionsMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/logging_elf/uncaught_exceptions_middleware.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, args = {}) ⇒ UncaughtExceptionsMiddleware

Returns a new instance of UncaughtExceptionsMiddleware.



4
5
6
7
# File 'lib/logging_elf/uncaught_exceptions_middleware.rb', line 4

def initialize(app, args = {})
  self.logger = args[:logger]
  @app = app
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



3
4
5
# File 'lib/logging_elf/uncaught_exceptions_middleware.rb', line 3

def logger
  @logger
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/logging_elf/uncaught_exceptions_middleware.rb', line 9

def call(env)
  begin
    response = @app.call env
  rescue => err
    logger.error err
    raise err
  end
  log_rack_exceptions(env)
  response
end