Skip to content

Commit

Permalink
Remove deprecated KubeException
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooli Tayer committed Jan 25, 2018
1 parent 8098547 commit 886d292
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 32 deletions.
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

0 comments on commit 886d292

Please sign in to comment.