Chapter 4. Error Handling
In most of the example programs so far, I either noted that they expected their input to be valid or ignored the possibility of problematic input altogether. There are situations in which we can get away with this, such as when a program is only for our own use or when we can be positively certain that there will be no unexpected input. In serious programs, however, some kind of disaster plan is usually needed.
Types of Problems
The problematic situations that a program can encounter can roughly be divided into two categories: programmer mistakes and run-time problems. If someone forgets to pass a required argument to a function, that is a programmer mistake. On the other hand, if a program asks the user to enter a name ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access