Class: GlobalErrorHandler::Middleware

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



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

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



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

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