summaryrefslogtreecommitdiff
path: root/lib/chef/formatters/error_inspectors/api_error_formatting.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/formatters/error_inspectors/api_error_formatting.rb')
-rw-r--r--lib/chef/formatters/error_inspectors/api_error_formatting.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/chef/formatters/error_inspectors/api_error_formatting.rb b/lib/chef/formatters/error_inspectors/api_error_formatting.rb
index 652d478b40..05ee3132a7 100644
--- a/lib/chef/formatters/error_inspectors/api_error_formatting.rb
+++ b/lib/chef/formatters/error_inspectors/api_error_formatting.rb
@@ -16,6 +16,8 @@
# limitations under the License.
#
+require 'chef/http/authenticator'
+
class Chef
module Formatters
@@ -65,6 +67,24 @@ E
error_description.section("Server Response:",format_rest_error)
end
+ def describe_406_error(error_description, response)
+ if response["x-ops-server-api-version"]
+ version_header = Chef::JSONCompat.from_json(response["x-ops-server-api-version"])
+ client_api_version = version_header["request_version"]
+ min_server_version = version_header["min_version"]
+ max_server_version = version_header["max_version"]
+
+ error_description.section("Incompatible server API version:",<<-E)
+This version of the API that this Chef request specified is not supported by the Chef server you sent this request to.
+The server supports a min API version of #{min_server_version} and a max API version of #{max_server_version}.
+Chef just made a request with an API version of #{client_api_version}.
+Please either update your Chef client or server to be a compatible set.
+E
+ else
+ describe_http_error(error_description)
+ end
+ end
+
def describe_500_error(error_description)
error_description.section("Unknown Server Error:",<<-E)
The server had a fatal error attempting to load the node data.