Class: AmazonDrs::Error

Inherits:
Base
  • Object
show all
Defined in:
lib/amazon-drs/error.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#date, #error_description_url, #error_type, #request_id, #status_code

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from AmazonDrs::Base

Instance Attribute Details

#errorObject

Returns the value of attribute error.



5
6
7
# File 'lib/amazon-drs/error.rb', line 5

def error
  @error
end

#error_descriptionObject

Returns the value of attribute error_description.



5
6
7
# File 'lib/amazon-drs/error.rb', line 5

def error_description
  @error_description
end

#messageObject

Returns the value of attribute message.



5
6
7
# File 'lib/amazon-drs/error.rb', line 5

def message
  @message
end

Instance Method Details

#inspectObject



14
15
16
17
18
19
20
21
# File 'lib/amazon-drs/error.rb', line 14

def inspect
  resp = 'ERROR'
  resp += " #{@error}" if instance_variable_defined?(:@error) && @error
  resp += ': '
  resp += @message if instance_variable_defined?(:@message) && @message
  resp += @error_description if instance_variable_defined?(:@error_description) && @error_description
  resp
end

#parse_body(body) ⇒ Object



7
8
9
10
11
12
# File 'lib/amazon-drs/error.rb', line 7

def parse_body(body)
  json = JSON.parse(body)
  @message = json['message'] if json['message']
  @error = json['error'] if json['error']
  @error_description = json['error_description'] if json['error_description']
end

#to_sObject



23
24
25
# File 'lib/amazon-drs/error.rb', line 23

def to_s
  inspect
end