Parent

DaemonKit::ErrorHandlers::Hoptoad

Error reporting via Hoptoad.

Attributes

api_key[RW]

Public Instance Methods

clean_exception( exception ) click to toggle source
# File lib/daemon_kit/error_handlers/hoptoad.rb, line 39
def clean_exception( exception )
  data = {
    :api_key       => self.api_key,
    :error_class   => exception.class.name,
    :error_message => "#{exception.class.name}: #{exception.message}",
    :backtrace     => exception.backtrace,
    :environment   => ENV.to_hash,
    :request       => {},
    :session       => {}
  }

  stringify_keys( data )
end
handle_exception( exception ) click to toggle source
# File lib/daemon_kit/error_handlers/hoptoad.rb, line 12
def handle_exception( exception )
  headers = {
    'Content-type' => 'application/x-yaml',
    'Accept' => 'text/xml, application/xml'
  }

  http = Net::HTTP.new( url.host, url.port )
  data = clean_exception( exception )

  response = begin
               http.post( url.path, {"notice" => data}.to_yaml, headers )
             rescue TimeoutError => e
               DaemonKit.logger.error("Timeout while contacting the Hoptoad server.")
               nil
             end
  case response
  when Net::HTTPSuccess then
    DaemonKit.logger.info "Hoptoad Success: #{response.class}"
  else
    DaemonKit.logger.error "Hoptoad Failure: #{response.class}\n#{response.body if response.respond_to? :body}"
  end
end
url() click to toggle source
# File lib/daemon_kit/error_handlers/hoptoad.rb, line 35
def url
  URI.parse("http://hoptoadapp.com/notices/")
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.