Class: Fog::Kubevirt::Utils::ExceptionWrapper
- Inherits:
-
Object
- Object
- Fog::Kubevirt::Utils::ExceptionWrapper
show all
- Defined in:
- lib/fog/kubevirt/compute/utils/exception_wrapper.rb
Instance Method Summary
collapse
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
|
# 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
if e.error_code == 409
@log.warn(e)
raise ::Fog::Kubevirt::Errors::AlreadyExistsError, e
elsif e.error_code == 404
raise ::Fog::Kubevirt::Errors::NotFoundError, e
else
@log.warn(e)
raise ::Fog::Kubevirt::Errors::ClientError, e
end
end
|
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
33
34
35
|
# File 'lib/fog/kubevirt/compute/utils/exception_wrapper.rb', line 33
def respond_to_missing?(method_name, include_private = false)
@client.respond_to?(method_name, include_private) || super
end
|
#version ⇒ Object
37
38
39
|
# File 'lib/fog/kubevirt/compute/utils/exception_wrapper.rb', line 37
def version
@version
end
|