diff --git a/cardano/backends/walletrest/__init__.py b/cardano/backends/walletrest/__init__.py index bf11934..8d99b5b 100644 --- a/cardano/backends/walletrest/__init__.py +++ b/cardano/backends/walletrest/__init__.py @@ -40,6 +40,9 @@ class WalletREST(object): "non_null_rewards": main_exceptions.NonNullRewards, "cannot_cover_fee": main_exceptions.CannotCoverFee, }, + 409: { + "wallet_already_exists": main_exceptions.WalletAlreadyExists, + }, 500: { "created_invalid_transaction": exceptions.CreatedInvalidTransaction, }, @@ -76,7 +79,7 @@ def raw_request(self, method, path, params=None): _log.debug(u"No result (HTTP 204)") if rsp.status_code == 400: raise exceptions.BadRequest(result["message"], result=result) - if rsp.status_code == 403: + if rsp.status_code in (403, 409): try: raise self.ERR2EXCEPTION[rsp.status_code][result["code"]]( result["message"] diff --git a/cardano/exceptions.py b/cardano/exceptions.py index 6638c7c..356e56c 100644 --- a/cardano/exceptions.py +++ b/cardano/exceptions.py @@ -10,6 +10,18 @@ class BackendException(CardanoException): pass +class WalletServiceException(CardanoException): + """The base exception for wallet service errors.""" + + pass + + +class WalletAlreadyExists(WalletServiceException): + """Raised when a duplicate wallet is requested to be created at the service.""" + + pass + + class WalletException(CardanoException): """The base exception for wallet errors."""