AQA A-level Computer Science (7517)Specification point 4.1.1.9

AQA 7517 4.1.1.9: Exception handling

The free BugBot lessons that teach this point, a robot to try it on, and the past-paper questions that test it.

What it covers

At GCSE you met runtime errors (F1.4) and validated input before using it (F6.1). A runtime error in Python is an exception: an object that describes what went wrong, raised at the moment it happens. If nothing handles it, the program stops and prints a message. On a laptop that is annoying; on a robot it can mean the motors are left running while the program that should stop them has ended. Exception handling lets a program catch an exception, deal with it, and carry on or shut down safely.

  • An unhandled exception
  • try and except
  • else, finally and as
  • Raising your own
  • Exceptions or checks?
Read the free lesson (20 min)

Or do it in the simulator, with tasks that mark themselves

Lessons that teach it

  1. A1.3 Exception handling Programming techniques and object-oriented programming
    try, except, else and finally, raising your own exceptions, and keeping the motors safe when something goes wrong.
  2. A1.10 Project: the behaviour controller Programming techniques and object-oriented programming
    Get past a wall to the dock with prioritised behaviour classes, a controller that aggregates them, and an exception to finish.

Try it on a robot

The task from A1.3 Exception handling, running here. Change the program and press Run.

The specification is AQA's own document; this page says which of our lessons teach point 4.1.1.9 and is not endorsed by the board.