Exception: Vra::Http::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/vra/http.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, http_code, response) ⇒ Error

Returns a new instance of Error.



157
158
159
160
161
# File 'lib/vra/http.rb', line 157

def initialize(message, http_code, response)
  super(message)
  @http_code = http_code
  @response = response
end

Instance Attribute Details

#http_codeObject (readonly)

Returns the value of attribute http_code.



149
150
151
# File 'lib/vra/http.rb', line 149

def http_code
  @http_code
end

#responseObject (readonly)

Returns the value of attribute response.



149
150
151
# File 'lib/vra/http.rb', line 149

def response
  @response
end

Class Method Details

.from_response(http_response) ⇒ Object



151
152
153
154
155
# File 'lib/vra/http.rb', line 151

def self.from_response(http_response)
  body = FFI_Yajl::Parser.parse(http_response.body) || {}
  message = body['message'] || body['serverMessage']
  new(message, http_response.code, body)
end