Home made exception hierarcy - 3



examples/exceptions/hierarchy3.py
import colors as cl

def main():
    print("start")

    try:
        cl.green()
    except cl.MyError as err:
        print(err)
        print(type(err).__name__)

    try:
        cl.blue()
    except cl.MyError as err:
        print(err)
        print(type(err).__name__)

    try:
        cl.red()
    except cl.MyError as err:
        print(err)
        print(type(err).__name__)




    print("done")


main()

start
Hulk
MyGreenError
Frozen
MyBlueError
Traceback (most recent call last):
  File "hierarchy3.py", line 30, in <module>
    main()
  File "hierarchy3.py", line 19, in main
    cl.red()
  File "/home/gabor/work/slides/python/examples/exceptions/colors.py", line 18, in red
    red_alert()
NameError: name 'red_alert' is not defined