class LoggingElf::UncaughtExceptionsMiddleware

Attributes

logger[RW]

Public Class Methods

new(app, args = {}) click to toggle source
# File lib/logging_elf/uncaught_exceptions_middleware.rb, line 4
def initialize(app, args = {})
  self.logger = args[:logger]
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# 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

Private Instance Methods

log_rack_exceptions(env) click to toggle source
# File lib/logging_elf/uncaught_exceptions_middleware.rb, line 22
def log_rack_exceptions(env)
  logger.error env['rack.exception'] if env['rack.exception']
end