Created
August 9, 2023 11:35
-
-
Save bbelderbos/a2fdbd62fa6fcf1eccb3e3edf987255d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TransactionLimitExceededError(Exception): | |
"""Raised when a transaction exceeds the allowed limit.""" | |
def __init__(self, amount, limit): | |
self.amount = amount | |
self.limit = limit | |
super().__init__(f"Transaction amount of {amount} exceeds the limit of {limit}.") | |
try: | |
raise TransactionLimitExceededError(500, 200) | |
except TransactionLimitExceededError as e: | |
print(f"Attempted transaction of {e.amount} exceeds the limit of {e.limit}.") | |
# outputs: | |
# Attempted transaction of 500 exceeds the limit of 200. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment