Sends out the notice to Airbrake
# 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
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
Generated with the Darkfish Rdoc Generator 2.