Class: Rack::Exceptional

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

Instance Method Summary collapse

Constructor Details

#initialize(app, api_key = nil) ⇒ Exceptional

Returns a new instance of Exceptional.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/exceptional/integration/rack.rb', line 7

def initialize(app, api_key = nil)
  @app = app
  if api_key.nil?
    exceptional_config = "config/exceptional.yml"
    ::Exceptional::Config.load(exceptional_config)
  else
    ::Exceptional.configure(api_key)
    ::Exceptional::Config.enabled = true
    ::Exceptional.logger.info "Enabling Exceptional for Rack"
  end
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/exceptional/integration/rack.rb', line 19

def call(env)
  begin
    status, headers, body =  @app.call(env)
  rescue Exception => e
    ::Exceptional::Catcher.handle_with_rack(e,env, Rack::Request.new(env))
    raise(e)
  end
end