Top Up Prev Next Bottom Contents Index Search

3.2 Handling Errors

Uniform handling of errors is provided by the Error class. The Error class provides four static methods, summarized in table 3-1. From within a star definition, it is not necessary to explicitly include the Error.h header file. A typical use of the class is shown below:

Error::abortRun(*this,"this message is displayed"); The notation "Error::abortRun" is the way static methods are invoked in C++ without having a pointer to an instance of the Error class. The first argument tells the error class which object is flagging the error; this is strongly recommended. The name of the object will be printed along with the error message. Note that the abortRun call does not cause an immediate halt. It simply marks a flag that the scheduler must test for.

The table uses standard C++ notation to indicate how to use the methods. The type of the return value and the type of the arguments is given, together with an explanation of each. When an argument has the annotation "= something," then this argument is optional. If it is omitted from the call, then the value used will be something.
Error class #include "Error.h"

method description
static void abortRun ( signal a fatal error, and request a halt to the run
const NamedObj& obj, the object triggering the error
const char*, the error message
const char* = 0, optional additional message to concatenate to the error message
const char* = 0) optional additional message to concatenate to the error message
static void abortRun signal a fatal error, and request a halt to the run
const char*, the error message
const char* = 0, optional additional message to concatenate to the error message
const char* = 0) optional additional message to concatenate to the error message
static void error (...) signal an error, without requesting a halt to the run
static void message (...) output a message to the user
static void warn (...) generate a warning message

TABLE 3-1: A summary of the static methods in the Error class. Each method has two templates, as shown only for the abortRun method. The others are the same.



Top Up Prev Next Bottom Contents Index Search

Copyright © 1990-1997, University of California. All rights reserved.