Exception: IOTServices::Evolens::ServerError

Inherits:
IOTServices::Error show all
Defined in:
lib/iot_services/evolens/errors.rb

Direct Known Subclasses

UnauthorizedError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ServerError

Returns a new instance of ServerError.



6
7
8
9
10
# File 'lib/iot_services/evolens/errors.rb', line 6

def initialize response
  super response_message(response)
  @code = response_code(response)
  @status = response.status
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



4
5
6
# File 'lib/iot_services/evolens/errors.rb', line 4

def code
  @code
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/iot_services/evolens/errors.rb', line 4

def status
  @status
end

Instance Method Details

#response_code(response) ⇒ Object



22
23
24
# File 'lib/iot_services/evolens/errors.rb', line 22

def response_code response
  response.body['error']['code'] if response.body['error']
end

#response_message(response) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/iot_services/evolens/errors.rb', line 12

def response_message response
  if response.body['error']
    response.body['error']['message']
  elsif response.body['Message']
    [response.body['Message'], response.body['MessageDetail']].join("\n")
  else
    'Error response not recognized'
  end
end