That’s amazon/ruby throwing an exception, just like ActiveRecord will if you call find with an invalid ID. There’s more about exceptions at:
What you want to do is to put your request to amazon/ruby inside a begin/rescue block. eg.
result = req.asin_search(asin_value.to_s)
Handle the error, redirect, or whatever
Handle the result, continue execution