Class: GlobalErrorHandler::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/global_error_handler/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



2
3
4
# File 'lib/global_error_handler/middleware.rb', line 2

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/global_error_handler/middleware.rb', line 6

def call(env)
  exception = nil
  status, headers, response = @app.call(env)
rescue Exception => exception
  GlobalErrorHandler::Handler.new(env, exception).process_exception!
ensure
  raise exception if exception
  [status, headers, response]
end