fork download
  1. # your code goes here
  2. class CustomException(Exception):
  3. pass
  4.  
  5. def custom_decorator(func):
  6. def wrapper(*args, **kwargs):
  7. try:
  8. result = func(*args, **kwargs)
  9. return result
  10. except CustomException as e:
  11. print(f"CustomException occurred: {str(e)}")
  12. return wrapper
  13.  
  14. @custom_decorator
  15. def divide(a, b):
  16. if b == 0:
  17. raise CustomException("Cannot divide by zero")
  18. return a / b
  19.  
  20. divide(10, 0)
Success #stdin #stdout 0.04s 9464KB
stdin
Standard input is empty
stdout
CustomException occurred: Cannot divide by zero