Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Remove deprecated KubeException #293

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
35 changes: 15 additions & 20 deletions lib/kubeclient/http_error.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions lib/kubeclient/resource_not_found_error.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module Kubeclient
# Exception that is raised when an http resource is not found
class ResourceNotFoundError < HttpError
end
end
12 changes: 0 additions & 12 deletions test/test_kubeclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down