Exceptions
Not met yet
An exception is Python stopping because something went wrong as the program ran. It has a type, like ValueError or ZeroDivisionError, and a message. It travels back up through every function that was called to get there, and if nothing catches it on the way, the whole program stops and prints the traceback. The bottom of the traceback is where it started.
Try it
main.pyOutput
Press Run and what your program prints shows up here.
Easy to get wrong
- Thinks an error inside a function only stops that function, and the code that called it carries on.
- Thinks Python skips a line that causes an error and carries on with the next one.