Class: ManageIQ::API::Client::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/manageiq/api/client/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status = 0, json_response = {}) ⇒ Error

Returns a new instance of Error.



10
11
12
# File 'lib/manageiq/api/client/error.rb', line 10

def initialize(status = 0, json_response = {})
  update(status, json_response)
end

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind.



6
7
8
# File 'lib/manageiq/api/client/error.rb', line 6

def kind
  @kind
end

#klassObject (readonly)

Returns the value of attribute klass.



8
9
10
# File 'lib/manageiq/api/client/error.rb', line 8

def klass
  @klass
end

#messageObject (readonly)

Returns the value of attribute message.



7
8
9
# File 'lib/manageiq/api/client/error.rb', line 7

def message
  @message
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/manageiq/api/client/error.rb', line 5

def status
  @status
end

Instance Method Details

#clearObject



14
15
16
# File 'lib/manageiq/api/client/error.rb', line 14

def clear
  update(0)
end

#update(status, json_response = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/manageiq/api/client/error.rb', line 18

def update(status, json_response = {})
  @status = status
  @kind, @message, @klass = nil
  error = json_response["error"]
  if status >= 400 && error.present?
    if error.kind_of?(Hash)
      @kind, @message, @klass = error.values_at("kind", "message", "klass")
    else
      @message = error
    end
  end
end