summaryrefslogtreecommitdiff
path: root/lib/chef/knife
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/knife')
-rw-r--r--lib/chef/knife/bootstrap/client_builder.rb2
-rw-r--r--lib/chef/knife/cookbook_delete.rb2
-rw-r--r--lib/chef/knife/cookbook_upload.rb2
-rw-r--r--lib/chef/knife/data_bag_create.rb2
-rw-r--r--lib/chef/knife/raw.rb2
-rw-r--r--lib/chef/knife/search.rb2
-rw-r--r--lib/chef/knife/supermarket_share.rb2
-rw-r--r--lib/chef/knife/supermarket_unshare.rb2
8 files changed, 8 insertions, 8 deletions
diff --git a/lib/chef/knife/bootstrap/client_builder.rb b/lib/chef/knife/bootstrap/client_builder.rb
index f5c49ab620..5fb0edc31b 100644
--- a/lib/chef/knife/bootstrap/client_builder.rb
+++ b/lib/chef/knife/bootstrap/client_builder.rb
@@ -187,7 +187,7 @@ class Chef
def resource_exists?(relative_path)
rest.get(relative_path)
true
- rescue Net::HTTPServerException => e
+ rescue Net::HTTPClientException => e
raise unless e.response.code == "404"
false
end
diff --git a/lib/chef/knife/cookbook_delete.rb b/lib/chef/knife/cookbook_delete.rb
index a4f64747c3..3de35d0a72 100644
--- a/lib/chef/knife/cookbook_delete.rb
+++ b/lib/chef/knife/cookbook_delete.rb
@@ -88,7 +88,7 @@ class Chef
@available_versions ||= rest.get("cookbooks/#{@cookbook_name}").map do |name, url_and_version|
url_and_version["versions"].map { |url_by_version| url_by_version["version"] }
end.flatten
- rescue Net::HTTPServerException => e
+ rescue Net::HTTPClientException => e
if e.to_s =~ /^404/
ui.error("Cannot find a cookbook named #{@cookbook_name} to delete.")
nil
diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb
index 4260ee01e2..02bea271b2 100644
--- a/lib/chef/knife/cookbook_upload.rb
+++ b/lib/chef/knife/cookbook_upload.rb
@@ -205,7 +205,7 @@ class Chef
def assert_environment_valid!
environment
- rescue Net::HTTPServerException => e
+ rescue Net::HTTPClientException => e
if e.response.code.to_s == "404"
ui.error "The environment #{config[:environment]} does not exist on the server, aborting."
Log.debug(e)
diff --git a/lib/chef/knife/data_bag_create.rb b/lib/chef/knife/data_bag_create.rb
index 563e931dca..bf90fb81b3 100644
--- a/lib/chef/knife/data_bag_create.rb
+++ b/lib/chef/knife/data_bag_create.rb
@@ -53,7 +53,7 @@ class Chef
begin
rest.get("data/#{@data_bag_name}")
ui.info("Data bag #{@data_bag_name} already exists")
- rescue Net::HTTPServerException => e
+ rescue Net::HTTPClientException => e
raise unless e.to_s =~ /^404/
# if it doesn't exists, try to create it
rest.post("data", { "name" => @data_bag_name })
diff --git a/lib/chef/knife/raw.rb b/lib/chef/knife/raw.rb
index a544dcbfdd..a9a757069b 100644
--- a/lib/chef/knife/raw.rb
+++ b/lib/chef/knife/raw.rb
@@ -112,7 +112,7 @@ class Chef
rescue Timeout::Error => e
ui.error "Server timeout"
exit 1
- rescue Net::HTTPServerException => e
+ rescue Net::HTTPClientException => e
ui.error "Server responded with error #{e.response.code} \"#{e.response.message}\""
ui.error "Error Body: #{e.response.body}" if e.response.body && e.response.body != ""
exit 1
diff --git a/lib/chef/knife/search.rb b/lib/chef/knife/search.rb
index 324c439ddc..168db6da1a 100644
--- a/lib/chef/knife/search.rb
+++ b/lib/chef/knife/search.rb
@@ -109,7 +109,7 @@ class Chef
result_items << formatted_item
result_count += 1
end
- rescue Net::HTTPServerException => e
+ rescue Net::HTTPClientException => e
msg = Chef::JSONCompat.from_json(e.response.body)["error"].first
ui.error("knife search failed: #{msg}")
exit 99
diff --git a/lib/chef/knife/supermarket_share.rb b/lib/chef/knife/supermarket_share.rb
index a47e16bd8c..bee90a9113 100644
--- a/lib/chef/knife/supermarket_share.rb
+++ b/lib/chef/knife/supermarket_share.rb
@@ -116,7 +116,7 @@ class Chef
data = noauth_rest.get("#{config[:supermarket_site]}/api/v1/cookbooks/#{@name_args[0]}")
data["category"]
rescue => e
- return "Other" if e.kind_of?(Net::HTTPServerException) && e.response.code == "404"
+ return "Other" if e.kind_of?(Net::HTTPClientException) && e.response.code == "404"
ui.fatal("Unable to reach Supermarket: #{e.message}. Increase log verbosity (-VV) for more information.")
Chef::Log.trace("\n#{e.backtrace.join("\n")}")
exit(1)
diff --git a/lib/chef/knife/supermarket_unshare.rb b/lib/chef/knife/supermarket_unshare.rb
index e2dfa33b86..98b6fa5789 100644
--- a/lib/chef/knife/supermarket_unshare.rb
+++ b/lib/chef/knife/supermarket_unshare.rb
@@ -48,7 +48,7 @@ class Chef
begin
rest.delete "#{config[:supermarket_site]}/api/v1/cookbooks/#{@name_args[0]}"
- rescue Net::HTTPServerException => e
+ rescue Net::HTTPClientException => e
raise e unless e.message =~ /Forbidden/
ui.error "Forbidden: You must be the maintainer of #{@cookbook_name} to unshare it."
exit 1