สร้าง custom exception class มี __init__ รับ variable
ตัวอย่าง
class ExampleException(Exception):
def __init__(self, foo):
self.foo = foo
try:
raise ExampleException("Bar!")
except ExampleException as e:
print(e.foo)
ผลลัพธ์
Bar!