Exception: SimpleStack::Exception

Inherits:
Exception
  • Object
show all
Defined in:
lib/simple_stack/exception.rb

Direct Known Subclasses

EntityNotFound, HypervisorError, NotImplemented

Class Method Summary collapse

Class Method Details

.factory(error) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/simple_stack/exception.rb', line 3

def self.factory(error)
  return Exception.new(error.inspect) if !error.is_a?(Hash)
  case error["error"]
  when "EntityNotFound"
    EntityNotFound.new(error["message"])
  when "FeatureNotImplemented"
    NotImplemented.new(error["message"])
  when "FeatureNotAvailable"
    NotImplemented.new(error["message"])
  when "HypervisorError"
    HypervisorError.new(error["message"])
  else
    Exception.new(error.inspect)
  end
end