diff --git a/README.md b/README.md index 8a2edf61..c7e6decf 100644 --- a/README.md +++ b/README.md @@ -476,6 +476,10 @@ client.process_template template ## Upgrading +### past version 3.0 + +Deprecated KubeException has been dropped, use `Kubeclient::HttpError` instead. + #### past version 2.0 Replace `KubeException` with `Kubeclient::HttpException` diff --git a/lib/kubeclient/http_error.rb b/lib/kubeclient/http_error.rb index 121368c2..53664271 100644 --- a/lib/kubeclient/http_error.rb +++ b/lib/kubeclient/http_error.rb @@ -1,25 +1,20 @@ -# TODO: remove this on next major version bump -# Deprected http exception -class KubeException < StandardError - attr_reader :error_code, :message, :response - - def initialize(error_code, message, response) - @error_code = error_code - @message = message - @response = response - end +module Kubeclient + # Exception that is raised when a http request fails + class HttpError < StandardError + attr_reader :error_code, :message, :response - def to_s - string = "HTTP status code #{@error_code}, #{@message}" - if @response.is_a?(RestClient::Response) && @response.request - string << " for #{@response.request.method.upcase} #{@response.request.url}" + def initialize(error_code, message, response) + @error_code = error_code + @message = message + @response = response end - string - end -end -module Kubeclient - # Exception that is raised when a http request fails - class HttpError < KubeException + def to_s + string = "HTTP status code #{@error_code}, #{@message}" + if @response.is_a?(RestClient::Response) && @response.request + string << " for #{@response.request.method.upcase} #{@response.request.url}" + end + string + end end end diff --git a/lib/kubeclient/resource_not_found_error.rb b/lib/kubeclient/resource_not_found_error.rb index 045a8364..5073803d 100644 --- a/lib/kubeclient/resource_not_found_error.rb +++ b/lib/kubeclient/resource_not_found_error.rb @@ -1,4 +1,5 @@ module Kubeclient + # Exception that is raised when an http resource is not found class ResourceNotFoundError < HttpError end end diff --git a/test/test_kubeclient.rb b/test/test_kubeclient.rb index 49045b82..ad534484 100644 --- a/test/test_kubeclient.rb +++ b/test/test_kubeclient.rb @@ -83,18 +83,6 @@ def test_exception assert_equal(409, exception.error_code) end - def test_deprecated_exception - error_message = 'certificate verify failed' - - stub_request(:get, 'http://localhost:8080/api') - .to_raise(OpenSSL::SSL::SSLError.new(error_message)) - - client = Kubeclient::Client.new('http://localhost:8080/api/') - - exception = assert_raises(KubeException) { client.api } - assert_equal(error_message, exception.message) - end - def test_api stub_request(:get, 'http://localhost:8080/api') .to_return(status: 200, body: open_test_file('versions_list.json'))