CSIRO Mathematics, Informatics and Statistics
|
|
|
Next: The LIAR ASC interface Up: No Title Previous: Coupling
The LIAR Error reporting and Message systemThere are many methods in which functions can report an error. The standard C run-time library mechanism predominately uses a global variable mechanism. However, this increases coupling and creates problems in asynchronous environments. Another technique that is commonly used--and is also to be avoided--is the use of error numbers and an associated write error module. In this latter approach, the caller passes an error-code number to the write error module, which then looks up the associated message in an error table that then gets printed out. The problem with this method is that it reduces observability, it is difficult to maintain because any modification affects the callee as well as the caller, and the calling routine actually losses control over its own messages. The LIAR uses the simplest of all approaches. Each function returns an error value. The return value from a function indicates whether an error has occured or not and it is ZERO if no error has occurred or a nonzero value if an error has occured. Also the error message text is to be placed with the code that detects the error. LIAR functions are not true functions in the classic sense: return values are communicated via parameters passed to LIAR functions by reference; that is, the input and output parameters are passed to the callee from the caller; for example:
Since a LIAR function cannot make assumptions about its environment, it cannot simply call printf or equivalent functions to put text on the screen. Rather this text must be controlled, so as to allow the system to display the messages in what ever fashion is suitable to its environment. Having said this, the LIAR message system does have a default display function called SHOWmsgs as seen in Table 1.
Next: The LIAR ASC interface Up: No Title Previous: Coupling Ed Breen Tue Sep 3 17:19:31 EST 1996 |