Custom Exception With Additional Attributes
Mon 10 August 2026
class TransactionError(Exception):
def __init__(self, code, message):
self.code = code
self.message = message
super().__init__(f"[{code}] {message}")
raise TransactionError(403, "Unauthorized action")
Score: 5
Category: chapter7_custom_exceptions