professional-programming/antipatterns/python-examples/reraise_exceptions_bad.py
2020-07-21 09:02:44 +02:00

20 lines
342 B
Python

from collections import namedtuple
Bread = namedtuple('Bread', 'color')
class ToastException(Exception):
pass
def toast(bread):
try:
put_in_toaster(bread)
except:
raise ToastException('Could not toast bread')
def put_in_toaster(bread):
brad.color = 'light_brown' # Note the typo
toast(Bread('yellow'))