Exception: AliexpressAPI::ResponseError

Inherits:
Error
  • Object
show all
Defined in:
lib/aliexpress_api/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, message = nil) ⇒ ResponseError

Returns a new instance of ResponseError.



14
15
16
17
# File 'lib/aliexpress_api/exceptions.rb', line 14

def initialize(response, message = nil)
  @response = response
  @message  = message
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



12
13
14
# File 'lib/aliexpress_api/exceptions.rb', line 12

def response
  @response
end

Instance Method Details

#to_sObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/aliexpress_api/exceptions.rb', line 19

def to_s
  message = +'Failed.'
  if response.respond_to?(:code)
    message << "  Response code = #{response.code}."
  end
  if response.respond_to?(:to_s)
    message << "  Response message = #{response}."
  end
  message
end