The dominance of object-oriented design has not eliminated the use of the procedural models of API design. Use of and adaptation to older but ubiquitous procedural APIs such as POSIX suggest using returns and/or the global errno
to communicate meaningful values corresponding to error conditions. Many POSIX calls, such as open(2)
,1 return an integer -1
on error and use a range of errno
values for the error details.
1. See http://pubs.opengroup.org/onlinepubs/000095399/functions/open.html.
We have explored various ways to inject values into our code for testing purposes. We use those same techniques to inject procedural error codes. Commonly, we will thinly encapsulate procedural system APIs such as POSIX such that they can be overridden for error-injection purposes. At other times, we will use a heavier encapsulation—sometimes as an available library—to fully translate the error semantics of the return value into an exception-based equivalent that fits more naturally into an object-oriented design.
The remainder of the chapter will focus on exception-based approaches to verification.
3.145.173.199