Error handling¶
The most basic error is AWSError
, which has attributes code
and
message
. Almost all operations raise specialised exceptions.
-
exception
amazonproduct.errors.
AWSError
(*args, **kwargs)¶ Generic AWS error message with the following attributes:
code
- The Amazon error code (e.g.
AWS.InvalidEnumeratedParameter
) msg
- The original error message from Amazon
xml
- XML returned from Amazon as processed by the API’s result processor
You can (and should) still pass additional arguments to derived exceptions which (as with
BaseException
) will be stored inargs
.
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¶
-
exception
amazonproduct.errors.
CartInfoMismatch
(*args, **kwargs)¶ Your request contains an invalid AssociateTag, CartId and HMAC combination. Please verify the AssociateTag, CartId, HMAC and retry.
Remember that all Cart operations must pass in the CartId and HMAC that were returned to you during the CartCreate operation.
-
exception
amazonproduct.errors.
DeprecatedOperation
(*args, **kwargs)¶ The specified feature (operation) is deprecated.
-
exception
amazonproduct.errors.
InternalError
(*args, **kwargs)¶ Amazon encountered an internal error. Please try again.
-
exception
amazonproduct.errors.
InvalidCartId
(*args, **kwargs)¶ Your request contains an invalid value for CartId. Please check your CartId and retry your request.
-
exception
amazonproduct.errors.
InvalidCartItem
(*args, **kwargs)¶ The item you specified, ???, is not eligible to be added to the cart. Check the item’s availability to make sure it is available.
-
exception
amazonproduct.errors.
InvalidClientTokenId
(*args, **kwargs)¶ The AWS Access Key Id you provided does not exist in Amazon’s records.
-
exception
amazonproduct.errors.
InvalidListType
(*args, **kwargs)¶ The value you specified for ListType is invalid. Valid values include: BabyRegistry, Listmania, WeddingRegistry, WishList.
-
exception
amazonproduct.errors.
InvalidOperation
(*args, **kwargs)¶ The specified feature (operation) is invalid.
-
exception
amazonproduct.errors.
InvalidParameterCombination
(*args, **kwargs)¶ Your request contained a restricted parameter combination.
-
exception
amazonproduct.errors.
InvalidParameterValue
(*args, **kwargs)¶ The specified ItemId parameter is invalid. Please change this value and retry your request.
-
exception
amazonproduct.errors.
InvalidResponseGroup
(*args, **kwargs)¶ The specified ResponseGroup parameter is invalid. Valid response groups for ItemLookup requests include:
Accessories, AlternateVersions, BrowseNodes, Collections, EditorialReview, Images, ItemAttributes, ItemIds, Large, ListmaniaLists, Medium, MerchantItemAttributes, OfferFull, OfferListings, OfferSummary, Offers, PromotionDetails, PromotionSummary, PromotionalTag, RelatedItems, Request, Reviews, SalesRank, SearchBins, SearchInside, ShippingCharges, Similarities, Small, Subjects, Tags, TagsSummary, Tracks, VariationImages, VariationMatrix, VariationMinimum, VariationOffers, VariationSummary, Variations.
-
exception
amazonproduct.errors.
InvalidSearchIndex
(*args, **kwargs)¶ The value specified for SearchIndex is invalid. Valid values include:
All, Apparel, Automotive, Baby, Beauty, Blended, Books, Classical, DVD, Electronics, ForeignBooks, HealthPersonalCare, HomeGarden, HomeImprovement, Jewelry, Kitchen, Magazines, MP3Downloads, Music, MusicTracks, OfficeProducts, OutdoorLiving, PCHardware, Photo, Shoes, Software, SoftwareVideoGames, SportingGoods, Tools, Toys, VHS, Video, VideoGames, Watches
-
exception
amazonproduct.errors.
ItemAlreadyInCart
(*args, **kwargs)¶ The item you specified, ???, is already in your cart.
Deprecated since version 0.2.6.
-
exception
amazonproduct.errors.
MissingClientTokenId
(*args, **kwargs)¶ Request must contain AWSAccessKeyId or X.509 certificate.
-
exception
amazonproduct.errors.
MissingParameters
(*args, **kwargs)¶ Your request is missing required parameters. Required parameters include XXX.
-
exception
amazonproduct.errors.
NoExactMatchesFound
(*args, **kwargs)¶ We did not find any matches for your request.
-
exception
amazonproduct.errors.
NoSimilarityForASIN
(*args, **kwargs)¶ When you specify multiple items, it is possible for there to be no intersection of similar items.
-
exception
amazonproduct.errors.
NotEnoughParameters
(*args, **kwargs)¶ Your request should have at least one parameter which you did not submit.
-
exception
amazonproduct.errors.
TooManyRequests
(*args, **kwargs)¶ You are submitting requests too quickly and your requests are being throttled. If this is the case, you need to slow your request rate to one request per second.
-
exception
amazonproduct.errors.
UnknownLocale
(*args, **kwargs)¶ Raised when unknown locale is specified.