Sha256: 544b1bbe84d0595e15b02d606b64cb87704d5bc406be3416418c21a67751a1bb
Contents?: true
Size: 1.37 KB
Versions: 13
Compression:
Stored size: 1.37 KB
Contents
module Errplane class Transmitter include Errplane::Logger HTTP_ERRORS = [ EOFError, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EINVAL, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, Timeout::Error ].freeze def initialize(params = {}) end def relay(black_box, deployment = false) http = initialize_http_connection data = black_box.to_json response = begin url = "/api/v1/applications/#{Errplane.configuration.application_id}/exceptions/#{Errplane.configuration.rails_environment}#{"/deploy" if deployment}?api_key=#{Errplane.configuration.api_key}" log :info, "URL: #{url}" log :info, "Data: #{data.inspect}" http.post(url, data) rescue *HTTP_ERRORS => e log :error, "HTTP error contacting Errplane API! #{e.class}: #{e.message}" end if response.is_a?(Net::HTTPSuccess) log :info, "Request Succeeded: #{response.inspect}" else log :error, "Request Failed: #{response.inspect}" end end private def initialize_http_connection connection = Net::HTTP.new(Errplane.configuration.api_host, "80") end end end
Version data entries
13 entries across 13 versions & 1 rubygems