Class: Flail::RackMiddlewareExceptionHook

Inherits:
Object
  • Object
show all
Defined in:
lib/flail/rack_middleware_exception_hook.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RackMiddlewareExceptionHook

Returns a new instance of RackMiddlewareExceptionHook.



3
4
5
# File 'lib/flail/rack_middleware_exception_hook.rb', line 3

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/flail/rack_middleware_exception_hook.rb', line 7

def call(env)
  begin
    response = @app.call(env)
  rescue ::Exception => exception
    Flail::Exception.new(env, exception).handle!
    raise
  end

  if env['rack.exception']
    Flail::Exception.new(env, env['rack.exception']).handle!
  end

  response
end