Introduction

Completed

Even the best-written code will have errors. Errors can happen because of updates, moved files, or other unexpected changes. Fortunately, Python offers rich support for tracking down and handling errors.

Scenario: Build a rocket program

Imagine you're a developer who's creating a program for a rocket. The program needs to read a configuration file to ensure that proper settings are loaded. Reading the file might cause an error if the file is missing or has other problems. In this module, you'll explore how to create the program.

What will I learn?

By the end of this module, you'll be able to:

  • Read and use error output from exceptions.
  • Properly handle exceptions.
  • Raise exceptions with useful error messages.
  • Use exceptions to control a program's flow.

What is the main objective?

In this module, you'll learn about using exception output for debugging, how to catch and raise exceptions, and how to affect a program's logic when exceptions happen.

Prerequisites

You should be familiar with the concept of programming.

You don't need to install Python to complete this module. You'll use an interactive sandbox to complete the exercises.

If you want to try out the code in the explanations, you might want to work through Get started with Python in Visual Studio Code first, if you haven't already. This module helps you prepare a Python environment.