Class: Exceptioner::Middleware

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



6
7
8
# File 'lib/exceptioner/middleware.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/exceptioner/middleware.rb', line 10

def call(env)
  begin
    response = @app.call(env)
  rescue Exception => exception
    Notifier.dispatch(exception, :controller => env['action_controller.instance'], :env => env)
    raise exception
  end
  if env['rack.exception']
    Notifier.dispatch(env['rack.exception'], :controller => env['action_controller.instance'], :env => env)
  end
  
  response
end