Skip to content

Commit

Permalink
Update InsufficientFundsError to have required_balance and `account…
Browse files Browse the repository at this point in the history
…_balance` fields
  • Loading branch information
MHHukiewitz committed Dec 4, 2023
1 parent ed04176 commit ef520a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/aleph/sdk/client/authenticated_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ async def create_instance(
account_balance = float(error["account_balance"])
required_balance = float(error["required_balance"])
raise InsufficientFundsError(
f"Account balance {account_balance} is not enough to create instance, required {required_balance}"
required_funds=required_balance, available_funds=account_balance
)
else:
raise ValueError(f"Unknown error code {error_code}: {rejected_message}")
Expand Down
10 changes: 9 additions & 1 deletion src/aleph/sdk/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,12 @@ class ForgottenMessageError(QueryError):
class InsufficientFundsError(Exception):
"""Raised when the account does not have enough funds to perform an action"""

pass
required_funds: float
available_funds: float

def __init__(self, required_funds: float, available_funds: float):
self.required_funds = required_funds
self.available_funds = available_funds
super().__init__(
f"Insufficient funds: required {required_funds}, available {available_funds}"
)

0 comments on commit ef520a0

Please sign in to comment.