44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/one_apm/collector/collector/helper.rb', line 44
def log_and_return_response(response)
OneApm::Manager.logger.debug "Received response, status: #{response.code}, encoding: '#{response['content-encoding']}'"
case response
when Net::HTTPSuccess
true when Net::HTTPUnauthorized
raise LicenseException, 'Invalid license key, please visit support.oneapm.com'
when Net::HTTPServiceUnavailable
raise ServerConnectionException, "Service unavailable (#{response.code}): #{response.message}"
when Net::HTTPGatewayTimeOut
raise ServerConnectionException, "Gateway timeout (#{response.code}): #{response.message}"
when Net::HTTPRequestEntityTooLarge
raise UnrecoverableServerException, '413 Request Entity Too Large'
when Net::HTTPUnsupportedMediaType
raise UnrecoverableServerException, '415 Unsupported Media Type'
else
raise ServerConnectionException, "Unexpected response from server (#{response.code}): #{response.message}"
end
response
end
|