Class: Fog::Rackspace::AutoScale::BadRequest

Inherits:
Errors::BadRequest show all
Defined in:
lib/fog/rackspace/auto_scale.rb

Instance Attribute Summary collapse

Attributes inherited from Errors::ServiceError

#response_data, #status_code, #transaction_id

Class Method Summary collapse

Methods inherited from Errors::BadRequest

#to_s

Methods inherited from Errors::ServiceError

extract_message, #set_transaction_id, #to_s

Instance Attribute Details

#validation_errorsObject (readonly)

Returns the value of attribute validation_errors.



12
13
14
# File 'lib/fog/rackspace/auto_scale.rb', line 12

def validation_errors
  @validation_errors
end

Class Method Details

.slurp(error, service = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fog/rackspace/auto_scale.rb', line 14

def self.slurp(error, service=nil)
  if error && error.response
    status_code = error.response.status
    if error.response.body
      body = Fog::JSON.decode(error.response.body)
      message = "#{body['type']} - #{body['message']}"
      details = error.response.body['details']
    end
  end

  new_error = new(message)
  new_error.set_backtrace(error.backtrace)
  new_error.instance_variable_set(:@validation_errors, details)
  new_error.instance_variable_set(:@status_code, status_code)
  new_error.set_transaction_id(error, service)
  new_error
end