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

remove deprecated exception #479

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@ Notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
Kubeclient release versioning follows [SemVer](https://semver.org/).

## Unreleased
### Removed
- removed KubeException, use `Kubeclient::HttpError`

## 4.9.1 — 2020-08-31
### Fixed
- Now should work with apiserver deployed not at root of domain but a sub-path,
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
12 changes: 0 additions & 12 deletions test/test_kubeclient.rb
Original file line number Diff line number Diff line change
@@ -96,18 +96,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'))