Method: Chef::Formatters::APIErrorFormatting#describe_406_error

Defined in:
lib/chef/formatters/error_inspectors/api_error_formatting.rb

#describe_406_error(error_description, response) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/chef/formatters/error_inspectors/api_error_formatting.rb', line 108

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 request specified is not supported by the 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}.
      #{ChefUtils::Dist::Infra::PRODUCT} just made a request with an API version of #{client_api_version}.
      Please either update your #{ChefUtils::Dist::Infra::PRODUCT} or the server to be a compatible set.
    E
  else
    describe_http_error(error_description)
  end
end