Parent

Airbrake::Sender

Sends out the notice to Airbrake

Attributes

host[R]
http_open_timeout[R]
http_read_timeout[R]
port[R]
protocol[R]
proxy_host[R]
proxy_pass[R]
proxy_port[R]
proxy_user[R]
secure[R]
secure?[R]
use_system_ssl_cert_chain[R]
use_system_ssl_cert_chain?[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/airbrake/sender.rb, line 15
def initialize(options = {})
  [ :proxy_host,
    :proxy_port,
    :proxy_user,
    :proxy_pass,
    :protocol,
    :host,
    :port,
    :secure,
    :use_system_ssl_cert_chain,
    :http_open_timeout,
    :http_read_timeout
  ].each do |option|
    instance_variable_set("@#{option}", options[option])
  end
end

Public Instance Methods

send_to_airbrake(notice) click to toggle source

Sends the notice data off to Airbrake for processing.

@param [Notice or String] notice The notice to be sent off

# File lib/airbrake/sender.rb, line 35
def send_to_airbrake(notice)
  data = notice.respond_to?(:to_xml) ? notice.to_xml : notice
  http = setup_http_connection

  response = begin
               http.post(url.path, data, HEADERS)
             rescue *HTTP_ERRORS => e
               log :level => :error,
                   :message => "Unable to contact the Airbrake server. HTTP Error=#{e}"
               nil
             end

  case response
  when Net::HTTPSuccess then
    log :level => :info,
        :message => "Success: #{response.class}",
        :response => response
  else
    log :level => :error,
        :message => "Failure: #{response.class}",
        :response => response,
        :notice => notice
  end

  if response && response.respond_to?(:body)
    error_id = response.body.match(%{<id[^>]*>(.*?)</id>})
    error_id[1] if error_id
  end
rescue => e
  log :level => :error,
    :message => "[Airbrake::Sender#send_to_airbrake] Cannot send notification. Error: #{e.class}" +
    " - #{e.message}\nBacktrace:\n#{e.backtrace.join("\n\t")}"

  nil
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.