From 4bc48594dde38004772ddc2c8aa9332ea29d95f6 Mon Sep 17 00:00:00 2001 From: Michael Grosser Date: Sun, 15 Nov 2020 21:39:02 -0800 Subject: [PATCH] remove deprecated exception --- CHANGELOG.md | 4 ++++ lib/kubeclient/http_error.rb | 35 +++++++++++++++-------------------- test/test_kubeclient.rb | 12 ------------ 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05c0ddc1..f4c55738 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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, 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/test/test_kubeclient.rb b/test/test_kubeclient.rb index be62c1b6..63e28075 100644 --- a/test/test_kubeclient.rb +++ b/test/test_kubeclient.rb @@ -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'))