diff options
author | tylercloke <tylercloke@gmail.com> | 2015-05-01 12:57:07 -0700 |
---|---|---|
committer | tylercloke <tylercloke@gmail.com> | 2015-05-04 13:18:30 -0700 |
commit | 2160fb4f917fb9f843c2bbd11093cbb1c2873482 (patch) | |
tree | 7e13ded35494df72ca54897bf4fc5b3d7b69c240 /lib | |
parent | ddf2135f147eca68490829dd96c65690c27f8d04 (diff) | |
download | chef-2160fb4f917fb9f843c2bbd11093cbb1c2873482.tar.gz |
Nice error formatting for unsupported API version in Knife.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/knife.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb index 2e0694aebc..4c59f831de 100644 --- a/lib/chef/knife.rb +++ b/lib/chef/knife.rb @@ -27,6 +27,7 @@ require 'chef/knife/core/subcommand_loader' require 'chef/knife/core/ui' require 'chef/local_mode' require 'chef/rest' +require 'chef/http/authenticator' require 'pp' class Chef @@ -483,6 +484,13 @@ class Chef when Net::HTTPServiceUnavailable ui.error "Service temporarily unavailable" ui.info "Response: #{format_rest_error(response)}" + when Net::HTTPNotAcceptable + min_version = Chef::JSONCompat.from_json(response.body)["min_version"] + max_version = Chef::JSONCompat.from_json(response.body)["max_version"] + ui.error "The version of Chef that Knife is using is not supported by the Chef server you sent this request to" + ui.info "This version of Chef requires a server API version of #{Chef::HTTP::Authenticator::SERVER_API_VERSION}" + ui.info "The Chef server you sent the request to supports a min API verson of #{min_version} and a max API version of #{max_version}" + ui.info "Please either update your Chef client or server to be a compatible set" else ui.error response.message ui.info "Response: #{format_rest_error(response)}" |