def humanize_http_exception(error_description)
response = exception.response
case response
when Net::HTTPUnauthorized
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}\"\nnode_name \"\#{username}\"\nclient_key \"\#{api_key}\"\n\nIf these settings are correct, your client_key may be invalid.\n")
when Net::HTTPForbidden
error_description.section("Authorization Error","Your client is not authorized to load one or more of your roles (HTTP 403).\n")
error_description.section("Server Response:", format_rest_error)
error_description.section("Possible Causes:","* Your client (\#{username}) may have misconfigured authorization permissions.\n")
when Net::HTTPInternalServerError
error_description.section("Unknown Server Error:","The server had a fatal error attempting to load a role.\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