Top Up Prev Next Bottom Contents Index Search

4.3 Class Error

Class Error is used for error reporting. While the interfaces to these functions are always the same, different user interfaces provide different implementations: ptcl connects to the Tcl error reporting mechanism, pigi pops up windows containing error messages, and interpreter simply prints messages on the standard error stream. All member functions of Error are static. There are four "levels" of messages that may be produced by the error facility: Error::abortRun is used to report an error and cause execution of the current universe to halt. Error::error reports an error. Error::warn reports a warning, and Error::message prints an information message that is not considered an error. Each of these four functions is available with two different signatures. For example:

static void abortRun (const char*, const char* = 0, const char* = 0);
static void abortRun (const NamedObj& obj, const char*, const char* = 0,
const char* = 0);
The first form produces the error message by simply concatenating its arguments (the second and third arguments may be omitted); no space is added. The second form prepends the full name of the obj argument, a colon, and a space to the text provided by the remaining arguments. If the implementation provides a marking facility, the object named by obj is marked by the user interface (at present, the interface associated with pigi will highlight the object if its icon appears on the screen). The remaining static Error functions error, warn, and message have the same signatures as does abortRun (there are the same two forms for each function). In addition, the Error class provides access to the marking facility, if it exists:

static int canMark(); 
This function returns TRUE if the interface can mark NamedObj objects (generally true for graphic interfaces), and FALSE if it cannot (generally true for text interfaces).

static void mark (const NamedObj& obj); 
This function marks the object obj, if marking is implemented for this interface. It is a no-op if marking is not implemented.

Top Up Prev Next Bottom Contents Index Search
Copyright © 1990-1997, University of California. All rights reserved.