Class: VagrantPlugins::Brightbox::Errors::FogError

Inherits:
VagrantBrightboxError show all
Defined in:
lib/vagrant-brightbox/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, *args) ⇒ FogError

Returns a new instance of FogError.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vagrant-brightbox/errors.rb', line 11

def initialize(message = nil, *args)
  if message.is_a?(Hash)
    target = message[:message]
    if target.respond_to?(:body)
      decode = Fog::JSON.decode(target.body)
      if decode["errors"] 
	message[:message] = decode["error_name"]+":\n"+decode["errors"].join("\n")
      elsif decode["error_description"]
        message[:message] = decode["error"] + ": " + decode["error_description"]
      end
    end
  end
  super
end