Class: Yeller::Rack

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Rack

Returns a new instance of Rack.



14
15
16
# File 'lib/yeller/rack.rb', line 14

def initialize(app)
  @app = app
end

Class Method Details

.configure(&block) ⇒ Object



6
7
8
# File 'lib/yeller/rack.rb', line 6

def self.configure(&block)
  @client = Yeller.client(&block)
end

.report(exception, options = {}) ⇒ Object



10
11
12
# File 'lib/yeller/rack.rb', line 10

def self.report(exception, options={})
  @client.report(exception, options)
end

.rescue_rack_exception(exception, env) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/yeller/rack.rb', line 27

def self.rescue_rack_exception(exception, env)
  request = ::Rack::Request.new(env)
  Yeller::Rack.report(
    exception,
    :url => request.url,
    :custom_data => {
      :params => request.params,
      :session => env.fetch('rack.session', {}),
  })
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/yeller/rack.rb', line 18

def call(env)
  begin
    @app.call(env)
  rescue Exception => exception
    Yeller::Rack.rescue_rack_exception(exception, env)
    raise exception
  end
end