Explaining the Language of Exception Handling in Python
1 min readSep 1, 2022
The aim of this pagešis to define a 4 core concepts needed to understand when talking about exceptions in python. Programs have a notion of normal path through the code, however:
- conditions can arise when it cannot follow
- exceptions are a standard way is a normal path cannot be followed
THE FOUR EXCEPTION HANDLING CONCEPTS
- raising an exception is an event of interupting a normal flow
- handling an exception is intentional processing of an exception within an enclosed context. the control flow is transfered to the exception handler. theretically, you can ignore it by using
pass
statement and force the return into the normal flow - unhandled exception is an exception that propagates up the callstack to the start of program. unhandled exception will cause program to terminate
- exception object is an object that is transfered between normal flow and exception flow.
- from: the point where the exception was raised
- to: the exception handler that interrogates it the exception object and take action