Class: ApiValve::Middleware::ErrorHandling

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ErrorHandling

Returns a new instance of ErrorHandling.



4
5
6
# File 'lib/api_valve/middleware/error_handling.rb', line 4

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
# File 'lib/api_valve/middleware/error_handling.rb', line 8

def call(env)
  @app.call(env)
rescue Exception => e # rubocop:disable Lint/RescueException
  log_error e
  self.class.const_get(ApiValve.error_responder).new(e).call
end