Exception: AliexpressAPI::ResultError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result, message: nil) ⇒ ResultError

Returns a new instance of ResultError.



49
50
51
52
# File 'lib/aliexpress_api/exceptions.rb', line 49

def initialize(result, message: nil)
  @result = result
  @message = message
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



47
48
49
# File 'lib/aliexpress_api/exceptions.rb', line 47

def result
  @result
end

Instance Method Details

#messageObject



54
55
56
# File 'lib/aliexpress_api/exceptions.rb', line 54

def message
  @message.present? ? @message : to_s
end

#to_sObject



58
59
60
61
62
# File 'lib/aliexpress_api/exceptions.rb', line 58

def to_s
  return "Failed. #{@result.to_json}." if @result.respond_to?(:to_json)

  "Failed. #{@result}."
end