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.



59
60
61
62
# File 'lib/cfoundry/errors.rb', line 59

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.



56
57
58
# File 'lib/cfoundry/errors.rb', line 56

def description
  @description
end

#error_codeObject (readonly)

Returns the value of attribute error_code.



56
57
58
# File 'lib/cfoundry/errors.rb', line 56

def error_code
  @error_code
end

Class Method Details

.error_classesObject



51
52
53
# File 'lib/cfoundry/errors.rb', line 51

def error_classes
  @error_classes ||= {}
end

Instance Method Details

#to_sObject

Exception message.



65
66
67
68
69
70
71
72
73
# File 'lib/cfoundry/errors.rb', line 65

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