docs.roxen.comView this page in a printer friendly mode
DocsPike7.0TutorialErrors and Error Handling
Copyright © 2012, Roxen Internet Software
Suggestions, comments & compliments
manuals@roxen.com
 DEMO  DOCS  PIKE
 COMMUNITY  DOWNLOAD
www.roxen.com

   

Error Messages from Pike
Error Handling: the Concept
Detecting an Error
Handling the Error
Error Codes
catch and throw

Error Handling: the Concept

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.