Skip to content

Commit

Permalink
Add exception for signalling wallet duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
emesik committed Jan 24, 2022
1 parent 5565f28 commit 7896e68
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cardano/backends/walletrest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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"]
Expand Down
12 changes: 12 additions & 0 deletions cardano/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down

0 comments on commit 7896e68

Please sign in to comment.