Chapter 2. Error-Handling Strategies

This chapter deals with patterns for handling errors appropriately so that their impact is mitigated and dealt with effectively. We first need to define the categories of software errors that can occur:

  • Domain errors are associated with a particular technology. They indicate that a problem that can be expected to happen at some point in time has occurred. An example of this type of error is getting KErrNotFound as a result of a multimedia application trying to open an audio file specified by the end user. The failure to find the file has a specific meaning for the software receiving the error.

  • System errors are the result of attempting some operation that fails due to a restriction of the system. KErrNoMemory is an obvious example, since it occurs whenever a memory allocation fails due to the memory constraints imposed by the system.

  • Faults occur because of programming errors. They result in abnormal conditions that cause a failure to execute the desired functionality of a particular system. Examples include null pointer dereferences and out-of-bound array accesses. User applications, core system services and the kernel can all suffer faults because of the same common factor: the human engineer.

Some other useful terms we should define here are:

  • Defect – also known as a bug, these are flaws, mistakes and failures in software that prevent it from behaving as intended. All faults are defects but not all defects are faults. For example, software ...

Get Common Design Patterns for Symbian OS: The Foundations of Smartphone Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.