Exception: CFoundry::APIError

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

Overview

Exception representing errors returned by the API.

Direct Known Subclasses

BadResponse, Denied, NotFound, UAAError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Create an APIError with a given request and response.



79
80
81
82
83
84
# File 'lib/cfoundry/errors.rb', line 79

def initialize(description = nil, error_code = nil, request = nil, response = nil)
  @response = response
  @request = request
  @error_code = error_code || (response ? response[:status] : nil)
  @description = description || parse_description
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



76
77
78
# File 'lib/cfoundry/errors.rb', line 76

def description
  @description
end

#error_codeObject (readonly)

Returns the value of attribute error_code.



76
77
78
# File 'lib/cfoundry/errors.rb', line 76

def error_code
  @error_code
end

#requestObject (readonly)

Returns the value of attribute request.



76
77
78
# File 'lib/cfoundry/errors.rb', line 76

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.



76
77
78
# File 'lib/cfoundry/errors.rb', line 76

def response
  @response
end

Class Method Details

.error_classesObject



71
72
73
# File 'lib/cfoundry/errors.rb', line 71

def error_classes
  @error_classes ||= {}
end

Instance Method Details

#request_traceObject



91
92
93
# File 'lib/cfoundry/errors.rb', line 91

def request_trace
  super(request)
end

#response_traceObject



95
96
97
# File 'lib/cfoundry/errors.rb', line 95

def response_trace
  super(response)
end

#to_sObject

Exception message.



87
88
89
# File 'lib/cfoundry/errors.rb', line 87

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