class Rnotifier::RackMiddleware

Public Class Methods

new(app, config_file = nil) click to toggle source
# File lib/rnotifier/rack_middleware.rb, line 4
def initialize(app, config_file = nil)
  @app = app
  config_file ? Rnotifier.load_config(config_file) : Rnotifier.config 
end

Public Instance Methods

call(env) click to toggle source
# File lib/rnotifier/rack_middleware.rb, line 9
def call(env)
  begin
    response = @app.call(env)
  rescue Exception => e
    Rnotifier::ExceptionData.new(e, env, {:type => :rack}).notify
    env['rnotifier.notify'] = true
    raise e
  end

  if e = (env['rack.exception'] || env['sinatra.error'])
    Rnotifier::ExceptionData.new(e, env, {:type => :rack}).notify
    env['rnotifier.notify'] = true
  end

  response
end