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



26
27
28
# File 'lib/yeller/rack.rb', line 26

def initialize(app)
  @app = app
end

Class Method Details

.clientObject



22
23
24
# File 'lib/yeller/rack.rb', line 22

def self.client
  @client
end

.configure(&block) ⇒ Object



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

def self.configure(&block)
  @config_blocks ||= []
  @config_blocks << block
  @client = Yeller.client(*@config_blocks)
end

.enabled?Boolean



17
18
19
20
# File 'lib/yeller/rack.rb', line 17

def self.enabled?
  return false unless @client
  @client.enabled?
end

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



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

def self.report(exception, options={})
  Yeller::VerifyLog.reporting_to_yeller_rack!
  @client.report(exception, options)
end

.rescue_rack_exception(exception, env) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/yeller/rack.rb', line 39

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



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

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