Class: Fog::Kubevirt::Utils::ExceptionWrapper
- Inherits:
-
Object
- Object
- Fog::Kubevirt::Utils::ExceptionWrapper
- Defined in:
- lib/fog/kubevirt/compute/utils/exception_wrapper.rb
Instance Method Summary collapse
-
#initialize(client, version, log) ⇒ ExceptionWrapper
constructor
A new instance of ExceptionWrapper.
- #method_missing(symbol, *args) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
- #version ⇒ Object
Constructor Details
#initialize(client, version, log) ⇒ ExceptionWrapper
Returns a new instance of ExceptionWrapper.
5 6 7 8 9 |
# File 'lib/fog/kubevirt/compute/utils/exception_wrapper.rb', line 5 def initialize(client, version, log) @client = client @version = version @log = log end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fog/kubevirt/compute/utils/exception_wrapper.rb', line 11 def method_missing(symbol, *args) super unless @client.respond_to?(symbol) if block_given? @client.__send__(symbol, *args) do |*block_args| yield(*block_args) end else @client.__send__(symbol, *args) end rescue KubeException => e @log.warn(e) case e.error_code when 401 raise ::Fog::Kubevirt::Errors::UnauthorizedError, e when 403 raise ::Fog::Kubevirt::Errors::ForbiddenError, e when 404 raise ::Fog::Kubevirt::Errors::NotFoundError, e when 409 raise ::Fog::Kubevirt::Errors::AlreadyExistsError, e else raise ::Fog::Kubevirt::Errors::ClientError, e end end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
37 38 39 |
# File 'lib/fog/kubevirt/compute/utils/exception_wrapper.rb', line 37 def respond_to_missing?(method_name, include_private = false) @client.respond_to?(method_name, include_private) || super end |
#version ⇒ Object
41 42 43 |
# File 'lib/fog/kubevirt/compute/utils/exception_wrapper.rb', line 41 def version @version end |