class ErrorappNotifier::Notifier
Attributes
data[R]
uniq_key[R]
Public Class Methods
new(data, uniq_key = nil)
click to toggle source
# File lib/errorapp_notifier/notifier.rb, line 6 def initialize(data, uniq_key = nil) @uniq_key = uniq_key @data = data end
notify_error(exception_data)
click to toggle source
# File lib/errorapp_notifier/notifier.rb, line 11 def self.notify_error(exception_data) new( exception_data.to_json, exception_data.uniq_key ).notify_error end
Public Instance Methods
notify_error()
click to toggle source
# File lib/errorapp_notifier/notifier.rb, line 18 def notify_error log_and_send do client.post(url, data) end end
Private Instance Methods
client()
click to toggle source
# File lib/errorapp_notifier/notifier.rb, line 63 def client client = optional_proxy.new(config.remote_host, config.remote_port) client.open_timeout = config.http_open_timeout client.read_timeout = config.http_read_timeout client.use_ssl = config.ssl? client.verify_mode = OpenSSL::SSL::VERIFY_NONE if config.ssl? client end
config()
click to toggle source
# File lib/errorapp_notifier/notifier.rb, line 53 def config ErrorappNotifier.configuration end
hash_param()
click to toggle source
# File lib/errorapp_notifier/notifier.rb, line 32 def hash_param unless uniq_key.nil? "&hash=#{uniq_key}" end end
log_and_send() { || ... }
click to toggle source
# File lib/errorapp_notifier/notifier.rb, line 38 def log_and_send begin response = yield case response when Net::HTTPSuccess ErrorappNotifier.logger.info("Error reported to Errorapp") else log_error(response.message) end rescue Exception => e log_error ErrorappNotifier.logger.error(e) end end
log_error(message = '')
click to toggle source
# File lib/errorapp_notifier/notifier.rb, line 57 def log_error(message = '') ErrorappNotifier.logger.error( "Problem notifying Errorapp about the error #{message}" ) end
optional_proxy()
click to toggle source
# File lib/errorapp_notifier/notifier.rb, line 72 def optional_proxy Net::HTTP::Proxy(config.http_proxy_host, config.http_proxy_port, config.http_proxy_username, config.http_proxy_password ) end
url()
click to toggle source
# File lib/errorapp_notifier/notifier.rb, line 28 def url "/api/projects/#{config.api_key}/fails?protocol_version=#{PROTOCOL_VERSION}#{hash_param}" end