1. Home
  2. Computing & Technology
  3. Python

Part 4: Handling Errors the Way You Want

From , former About.com Guide

5 of 7

Reading Python's Error Message: Part 2

The question mark in the first error message denotes an error that occurred in the base part of the program. The main() function is called there on line 92. Then, within the main() function, on line 87, there was a problem in the execution of function formBody(). Within formBody, on line 82, there was an error in calling the feeddata() method of object feed. Within feeddata(), there was a problem at line 53 of the program in assigning the value of feedinfo[feedname] to feedaddress. If you do not understand how parts of those functions and methods worked, you will want to follow the links to the respective discussions about each.

When we realise that the problem lies with the assignment to feedaddress, we then look at the source of that assignment, the dictionary feedinfo, which is defined when getlistinfo() is called. That function takes its values from "feedlist.dat" because "dat" is the argument passed in the assignment of feedaddress. As the data file does not draw from anywhere else but is relatively static, the troubleshooting quest ends there. We can now see where the problem lies, even without knowing the precise problem, and we thus know the component of the program that we must examine in greater depth.

The question still remains, however: What to do about it? Go to the next page to see how we will add error handling to this program.

Explore Python
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Python

©2009 About.com, a part of The New York Times Company.

All rights reserved.