Commit 829e2343 authored by Lamont Granquist's avatar Lamont Granquist
Browse files

properly catching all the exception types that Net::HTTP can throw

parent 05eb8b28
......@@ -115,16 +115,16 @@ class Chef
@run_id = ::File.basename(run_uri.path)
Chef::Log.info("Chef server generated run history id: #{@run_id}")
@summary_only = server_response["summary_only"]
rescue Net::HTTPServerException => e
if e.response.code.to_s == "404"
Chef::Log.debug("Received 404 attempting to generate run history id (URL Path: #{resource_history_url}), assuming feature is not supported.")
else
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
if !e.response || e.response.code.to_s != 404
if Chef::Config[:enable_reporting_url_fatals]
Chef::Log.error("Received #{e.response.code} attempting to generate run history id (URL Path: #{resource_history_url}), and enable_reporting_url_fatals is set, aborting run.")
Chef::Log.error("Received exception attempting to generate run history id (URL Path: #{resource_history_url}), and enable_reporting_url_fatals is set, aborting run.")
raise
else
Chef::Log.info("Received #{e.response.code} attempting to generate run history id (URL Path: #{resource_history_url}), disabling reporting for this run.")
Chef::Log.info("Received exception attempting to generate run history id (URL Path: #{resource_history_url}), disabling reporting for this run.")
end
else
Chef::Log.debug("Received 404 attempting to generate run history id (URL Path: #{resource_history_url}), assuming feature is not supported.")
end
@reporting_enabled = false
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment