Exceptions
Computer Science: KS3, topic 2.3.13
Exceptions
Normally, an error would crash the program. Exceptions give us a chance to handle the error more gracefully.

Exceptions
- An error arises in a program.
- The program is said to 'throw' an exception.
- An exception is a description of the error that arose.
- Exceptions can be 'caught' or handled rather than allowing the program to crash.

Handling exceptions
- If an exception can be dealt with internally, we catch it and continue the program.
- Catching exceptions is done using a structure as below:
- try: ---
- except: ---
- The code within the try block will be executed.
- If an exception is thrown in the try block, the except block will 'clean up'.
Test yourself on Exceptions
What is it called when an error arises in a program?
What is the purpose of the 'except' block of a try-except structure?
Pick the sentence that is true.
A program's code has an error. One version has no exception handling. Another version catches the error. What happens in each version?