Exception: AmazonAds::Error
- Inherits:
-
StandardError
- Object
- StandardError
- AmazonAds::Error
- Defined in:
- lib/amazon_ads/error.rb
Overview
Raised when the API or LWA responds with a 4xx or 5xx
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
The failed response.
Class Method Summary collapse
Instance Method Summary collapse
-
#deconstruct_keys(keys) ⇒ Object
Supports pattern matching on status.
-
#initialize(msg = nil, response = nil) ⇒ Error
constructor
A new instance of Error.
- #status ⇒ Object
Constructor Details
#initialize(msg = nil, response = nil) ⇒ Error
Returns a new instance of Error.
18 19 20 21 |
# File 'lib/amazon_ads/error.rb', line 18 def initialize(msg = nil, response = nil) @response = response super(msg) end |
Instance Attribute Details
#response ⇒ Object (readonly)
The failed response
9 10 11 |
# File 'lib/amazon_ads/error.rb', line 9 def response @response end |
Class Method Details
.build(response) ⇒ Object
12 13 14 15 |
# File 'lib/amazon_ads/error.rb', line 12 def self.build(response) response.flush # memoize the body while the connection is still readable new(response.status.to_s, response) end |
Instance Method Details
#deconstruct_keys(keys) ⇒ Object
Supports pattern matching on status
case error
in status: 429 then backoff
in status: 500..599 then retry
end
36 37 38 39 |
# File 'lib/amazon_ads/error.rb', line 36 def deconstruct_keys(keys) hash = { status: status } keys ? hash.slice(*keys) : hash end |
#status ⇒ Object
24 25 26 |
# File 'lib/amazon_ads/error.rb', line 24 def status response&.status&.code end |