Skip to content

Commit ef520a0

Browse files
committed
Update InsufficientFundsError to have required_balance and account_balance fields
1 parent ed04176 commit ef520a0

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/aleph/sdk/client/authenticated_http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ async def create_instance(
583583
account_balance = float(error["account_balance"])
584584
required_balance = float(error["required_balance"])
585585
raise InsufficientFundsError(
586-
f"Account balance {account_balance} is not enough to create instance, required {required_balance}"
586+
required_funds=required_balance, available_funds=account_balance
587587
)
588588
else:
589589
raise ValueError(f"Unknown error code {error_code}: {rejected_message}")

src/aleph/sdk/exceptions.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,12 @@ class ForgottenMessageError(QueryError):
6969
class InsufficientFundsError(Exception):
7070
"""Raised when the account does not have enough funds to perform an action"""
7171

72-
pass
72+
required_funds: float
73+
available_funds: float
74+
75+
def __init__(self, required_funds: float, available_funds: float):
76+
self.required_funds = required_funds
77+
self.available_funds = available_funds
78+
super().__init__(
79+
f"Insufficient funds: required {required_funds}, available {available_funds}"
80+
)

0 commit comments

Comments
 (0)