Tools.h++ Manual
104011 Tandem Computers Incorporated 18-1
Errors 18
Thinking about error handling is like thinking about where the garbage man
hauls your trash—it’s a messy, unpredicatable, and sour topic, one that we
don’t like to think about. Yet, to write robust code, think about it we must.
The Tools.h++ class libraries use an extensive and complete error handling
facility, all based on the same model. Errors are divided into two broad
categories: internal errors and external errors. The distinguishing characteristic
of internal errors is that they are due to errors in the internal logic of the
program. As you might expect, they can be difficult to recover from and,
indeed, the default response is commonly to abort the program. External errors
are due to events beyond the scope of the program. Any non-trivial program
should be prepared to recover from an external error.
The following sections describe the error model in detail.
18.1 Internal errors
Internal errors are due to faulty logic or coding in the program. Examples are
• Bounds errors;
• Inserting a null pointer into a collection;
• Attempting to use a bad date.