def humanize_http_exception(error_description)
response = exception.response
case response
when Net::HTTPUnauthorized
if clock_skew?
error_description.section("Authentication Error:","Failed to authenticate to the chef server (http 401).\nThe request failed because your clock has drifted by more than 15 minutes.\nSyncing your clock to an NTP Time source should resolve the issue.\n")
else
error_description.section("Authentication Error:","Failed to authenticate to the chef server (http 401).\n")
error_description.section("Server Response:", format_rest_error)
error_description.section("Relevant Config Settings:","chef_server_url \"\#{server_url}\"\nvalidation_client_name \"\#{username}\"\nvalidation_key \"\#{api_key}\"\n\nIf these settings are correct, your validation_key may be invalid.\n")
end
when Net::HTTPForbidden
error_description.section("Authorization Error:","Your validation client is not authorized to create the client for this node (HTTP 403).\n")
error_description.section("Possible Causes:","* There may already be a client named \"\#{config[:node_name]}\"\n* Your validation client (\#{username}) may have misconfigured authorization permissions.\n")
when Net::HTTPBadRequest
error_description.section("Invalid Request Data:","The data in your request was invalid (HTTP 400).\n")
error_description.section("Server Response:",format_rest_error)
when Net::HTTPNotFound
error_description.section("Resource Not Found:","The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.\n")
error_description.section("Relevant Config Settings:","chef_server_url \"\#{server_url}\"\n")
when Net::HTTPInternalServerError
error_description.section("Unknown Server Error:","The server had a fatal error attempting to load the node data.\n")
error_description.section("Server Response:", format_rest_error)
when Net::HTTPBadGateway, Net::HTTPServiceUnavailable
error_description.section("Server Unavailable","The Chef Server is temporarily unavailable")
error_description.section("Server Response:", format_rest_error)
else
error_description.section("Unexpected API Request Failure:", format_rest_error)
end
end