Class: CrashHook::Middleware

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Middleware

Returns a new instance of Middleware.


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

def initialize(app, options={})
  @app = app
  @config = CrashHook.configure(options)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config


3
4
5
# File 'lib/crash_hook/middleware.rb', line 3

def config
  @config
end

Instance Method Details

#call(env) ⇒ Object


10
11
12
13
14
15
16
17
# File 'lib/crash_hook/middleware.rb', line 10

def call(env)
  @app.call(env)
  rescue Exception => exception
  unless @config.ignore_exception?(exception.class.to_s)
    CrashHook::Crash.new(@config, exception, env).notify
  end
  raise exception
end