Class: Rack::Banken::ExceptionHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/banken/exception_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ExceptionHandler

Returns a new instance of ExceptionHandler.



5
6
7
# File 'lib/rack/banken/exception_handler.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rack/banken/exception_handler.rb', line 9

def call(env)
  begin
    @app.call(env)

  rescue Exceptions::Base => e
    raise e.class, e.message

  rescue => e
    raise Exceptions::InternalServerError, e.message
  end

rescue  Exceptions::Base => exception
  exception.to_rack_response
end