Class: WhoopsRailsNotifier::Rack

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

Overview

Middleware for Rack applications. Any errors raised by the upstream application will be delivered to whoops and re-raised.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Rack

Returns a new instance of Rack.



5
6
7
# File 'lib/whoops_rails_notifier/rack.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/whoops_rails_notifier/rack.rb', line 9

def call(env)
  begin
    response = @app.call(env)
  rescue Exception => raised
    evidence = {
      :exception => raised,
      :rack_env  => env
    }
    WhoopsNotifier.notify(:rails_exception, evidence)
    raise
  end

  response
end