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

Denied, NotFound, TargetRefused, UploadFailed

Class Attribute 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.



20
21
22
23
# File 'lib/cfoundry/errors.rb', line 20

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

Class Attribute Details

.descriptionObject (readonly)

Generic description for the exception.



9
10
11
# File 'lib/cfoundry/errors.rb', line 9

def description
  @description
end

.error_codeObject (readonly)

Generic error code for the exception.



6
7
8
# File 'lib/cfoundry/errors.rb', line 6

def error_code
  @error_code
end

Instance Method Details

#descriptionObject

A description of the error.



31
32
33
# File 'lib/cfoundry/errors.rb', line 31

def description
  @description || self.class.description
end

#error_codeObject

A number representing the error.



26
27
28
# File 'lib/cfoundry/errors.rb', line 26

def error_code
  @error_code || self.class.error_code
end

#to_sObject

Exception message.



36
37
38
39
40
41
42
# File 'lib/cfoundry/errors.rb', line 36

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