Not logged in

When you examine a program that is intended to solve a real problem in the real world, a surprisingly large portion of the program will be written just to take care of possible errors. Even in the simple web browser from the example earlier in this tutorial, which hardly qualifies as a real-world program, we had to handle no less than three possible errors:

  • An incorrect number of command-line arguments to the program.

  • The user didn't write a web address, and just pressed the return key instead.

  • The browser couldn't download the web page from the given address.

Error handling usually consists of two parts: detecting the error, and handling it.