Handle errors in version 7
masterIn version 7, errors are mapped directly from the Creators API response. While except RequestError still catches 401 (AuthenticationError) and 403 (AccessDeniedError), a 400 error that previously raised RequestError now raises InvalidArgumentError.
To catch all library-specific errors, catch AmazonCreatorsApiError. Note that error messages now include specific details from Amazon, such as the rejected fields and request identifier, so any logic relying on exact error message text should be reviewed.
from amazon_creatorsapi.errors import AmazonCreatorsApiError
try:
items = api.get_items(["B01N5IB20Q"])
except AmazonCreatorsApiError as error: # Catches every error of the library
print(error)