Exception: CFoundry::APIError

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/cfoundry/errors.rb

Overview

Exception representing errors returned by the API.

Direct Known Subclasses

BadResponse, Denied, NotFound

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_code = nil, description = nil) ⇒ APIError

Create an APIError with a given error code and description.



45
46
47
48
# File 'lib/cfoundry/errors.rb', line 45

def initialize(error_code = nil, description = nil)
  @error_code = error_code
  @description = description
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



42
43
44
# File 'lib/cfoundry/errors.rb', line 42

def description
  @description
end

#error_codeObject (readonly)

Returns the value of attribute error_code.



42
43
44
# File 'lib/cfoundry/errors.rb', line 42

def error_code
  @error_code
end

Class Method Details

.error_classesObject



37
38
39
# File 'lib/cfoundry/errors.rb', line 37

def error_classes
  @error_classes ||= {}
end

Instance Method Details

#to_sObject

Exception message.



51
52
53
54
55
56
57
58
59
# File 'lib/cfoundry/errors.rb', line 51

def to_s
  if error_code
    "#{error_code}: #{description}"
  elsif description
    description
  else
    super
  end
end