Module: Bullhorn::Sender

Extended by:
Sender
Included in:
Bullhorn, Sender
Defined in:
lib/bullhorn/sender.rb

Instance Method Summary collapse

Instance Method Details

#notify(exception, env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bullhorn/sender.rb', line 9

def notify(exception, env)
  bt = Backtrace.new(exception, :context => @show_code_context)

  Net::HTTP.post_form(URI(url), {
    :api_key      => api_key,
    :message      => exception.message,
    :backtrace    => serialize(bt.to_a),
    :env          => serialize(whitelist(env)),
    :request_body => serialize(whitelist(request_body(env))),
    :sha1         => sha1(exception),
    # APIv2
    :language       => Bullhorn::LANGUAGE,
    :client_name    => Bullhorn::CLIENT_NAME,
    :client_version => Bullhorn::VERSION,
    :url            => [ "http://", env['HTTP_HOST'], env['REQUEST_URI'] ].join(''),
    :class          => exception.class.to_s
  })
end

#serialize(str) ⇒ Object



5
6
7
# File 'lib/bullhorn/sender.rb', line 5

def serialize(str)
  Base64.encode64(str.to_json).strip
end