Handle Amazon Product API errors
I'm breaking this out of #56 since it's really a different issue.
The Issue
Sometimes, Amazon queries return errors. The current behavior is that the page stays blank. We should have a graceful way of handling this that gives some clue about the problem.
Here are the errors I've encountered so far (to give a sense of how they look):
-
"Error"=>{"Code"=>"SignatureDoesNotMatch", "Message"=>"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."} -
"Error"=>{"Code"=>"RequestThrottled", "Message"=>"AWS Access Key ID: <redacted>. You are submitting requests too quickly. Please retry your requests at a slower rate."} -
"Error"=>{"Code"=>"AWS.InvalidParameterValue", "Message"=>"{:ASIN=>\"B00TFT77ZS\"} is not a valid value for ItemId. Please change this value and retry your request."}}
And here's an example error response for the ItemLookup endpoint: gist
Reproducing the Issue
The easiest error to reproduce: search for an item with a ' character (ex. k'nex) (until #56 is solved).
Task
We should handle Amazon error responses in a generic way. Maybe re-render the search page with an flash alert? Display a different error page?
We should also make sure any sensitive data (ex. keys) are redacted from the displayed messages.
Do any of these errors need special handling? I assume the Amazon API docs list all possible errors.
@leesharma I would like to take a shot at this issue. Do you have any extra details on the issue before I get started?
@hmasila Not at the moment! This will probably require playing around with the response classes (lib/amazon_product_api/*_response.rb) to hold/handle errors.
@leesharma I think I would like to try to solve this, but I wasn't sure if someone was already working on it. Is it ok if I pick this issue up?