Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
odesenfans committed Oct 3, 2023
1 parent 2ad7568 commit ec8f301
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/aleph/types/message_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def __init__(
errors = [errors]
super().__init__(errors)

def __str__(self):
# TODO: reimplement for each exception subtype
return self.__class__.__name__

def details(self) -> Optional[Dict[str, Any]]:
errors = self.args[0]
return {"errors": errors} if errors else None
Expand Down Expand Up @@ -301,9 +305,11 @@ def details(self) -> Optional[Dict[str, Any]]:

class InsufficientBalanceException(InvalidMessageException):
"""
You don't have enough in balance
The user does not have enough Aleph tokens to process the message.
"""

error_code = ErrorCode.BALANCE_INSUFFICIENT

def __init__(
self,
balance: Decimal,
Expand All @@ -314,6 +320,11 @@ def __init__(

def details(self) -> Optional[Dict[str, Any]]:
# Note: cast to string to keep the precision
return {"errors": [{"required_balance": str(self.required_balance), "account_balance": str(self.balance)}]}

error_code = ErrorCode.BALANCE_INSUFFICIENT
return {
"errors": [
{
"required_balance": str(self.required_balance),
"account_balance": str(self.balance),
}
]
}

0 comments on commit ec8f301

Please sign in to comment.