Skip to content

Commit

Permalink
Added exception for country availabiliy
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioteula committed Jul 19, 2021
1 parent 64f5a44 commit 0bc349c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions amazon_paapi/errors/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ class TooManyRequestsException(AmazonException):
class InvalidPartnerTagException(AmazonException):
"""Raised if the partner tag is not present or invalid"""
pass

class AssociateValidationException(AmazonException):
"""Raised when credentials are not valid for the selected country."""
pass
6 changes: 4 additions & 2 deletions amazon_paapi/helpers/requests.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"""Module with helper functions for creating requests."""


from amazon_paapi.errors.exceptions import InvalidArgumentException
from typing import List
from ..models.item_result import Item
from ..models.search_result import SearchResult
from ..models.variations_result import VariationsResult
from ..models.browse_nodes_result import BrowseNode
from ..errors import ApiRequestException, ItemsNotFoudException, MalformedRequestException, TooManyRequestsException
from ..errors import ApiRequestException, ItemsNotFoudException, MalformedRequestException, TooManyRequestsException, AssociateValidationException, InvalidArgumentException
from ..sdk.models.partner_type import PartnerType
from ..sdk.models.get_items_resource import GetItemsResource
from ..sdk.models.get_items_request import GetItemsRequest
Expand Down Expand Up @@ -130,4 +129,7 @@ def _manage_response_exceptions(error) -> None:
elif 'InvalidPartnerTag' in error.body:
raise InvalidArgumentException('The partner tag is invalid or not present.')

elif 'InvalidAssociate' in error.body:
raise AssociateValidationException('Used credentials are not valid for the selected country.')

raise ApiRequestException('Request failed: ' + str(error.reason))

0 comments on commit 0bc349c

Please sign in to comment.