Source

python-amazon-product-api / docs / source / errors.rst

Full commit

Error handling

The most basic error is AWSError, which has attributes code and message. Almost all operations raise specialised exceptions.

Sometimes you may still want to access the original response. An example:

try:
    result = api.item_lookup(
        ['644209004461', '009800895250', '301357583001'], IdType='UPC')
except InvalidParameterValue, e:
    print 'There was an invalid ItemId!' # '301357583001'
    result = e.xml

Although UPC 301357583001 will cause an error to be raised, you can retrieve the parsed response (here result is simply replaced with e.xml) and continue working on it as if nothing has happened.

Occurring exceptions