SYNOPSIS
#include "matrix.h" ERREXIT(); ERRABORT(); ON_ERROR();
DESCRIPTION
If ERREXIT() is called, then the program exits once the error occurs, and the error message is printed. {\bf This is the default.} If ERRABORT() is called, then the program aborts once the error occurs, and the error message is printed. Aborting in Unix systems means that a core file is dumped and can be analysed, for example, by (symbolic) debuggers. Behaviour on non-Unix systems is undefined. If ON_ERROR() is called, the current place is set as the default return point if an error is raised, though this can be modified by the catch() macro. The ON_ERROR() call can be put at the beginning of a main program so that control always returns to the start. One way of using it is as follows:
main() { ...... ON_ERROR(); printf("At start of program; restarts on error\n"); /* initialisation stuff here */ ...... /* real work here */ ...... }This is a slightly dangerous way of doing things, but may be useful for implementing matrix calculator type programs. Other, more sophisticated, things can be done with error handlers and error handling, though the topic is too advanced to be treated in detail here.
SEE ALSO: error() and ev_err().
BUGS
With all of these routines, care must be taken not to use them inside called functions, unless the calling function immediately re-sets the restart buffer after the called function returns. Otherwise the restart buffer will reference a point on the stack which will be overwritten by subsequent calculations and function calls. This is a problem inherent in the use of setjmp() and longjmp(). The only way around this problem is through the implementation of co-routines. With ON_ERROR(), infinite loops can occur very easily.
SOURCE FILE: matrix.h