next up previous contents
Next: Reporting Errors In GRASP Up: GRASP Routines: General purpose Previous: GRASP Routines: General purpose   Contents

GRASP Error Handling

0

GR_error is the GRASP error reporting module. It has two abstract interfaces which insulate the GRASP library and the programs which use it from the details of how GRASP will report errors and how the program will handle them. The internal interface provides GRASP itself with a standard method to report errors. The external interface allows programs which use GRASP to specify exactly how error reports are to be handled. In addition, a default set of handling routines is provided for printing error messages in a standard format to stderr or a log file.

If you are writing a package for GRASP, here is an example of how to call the error handler. The following sections contain more detailed information, but this example is a userful summary of ``how to use it''. Please note that you must include ``newline" characters ${\tt\backslash n}$ in your GR_report_error() calls. If you fail to do this the lines of error messages will all be strung together on a single line!

...
/* first call GR_start_error() to begin the error message */
GR_start_error("trouble()",rcsid,__FILE__,__LINE__);
/* then call GR_report_error() as many times as desired */
GR_report_error("The GR_report_error() function is like printf().\n");
GR_report_error("It can have no arguments.\n");
GR_report_error("It can have a float argument %f\n",x1);
GR_report_error("Or any mixture of valid types %d %d %%s\n",i1,i2,stringptr);
/* finally, call GR_end_error() to terminate the error message */
GR_end_error();
...
The use of these three routines as shown will print out, for example:
GRASP: Message from function trouble() at line number 123 of file "source.c".
The GR_report_error() function is like printf().
It can have no arguments.
It can have a float argument 5.43210
Or any mixture of valid types -2 17 the string pointed to by the pointer
$Id: man_utility.tex,v 1.38 1999/07/11 21:22:18 ballen Exp $
$Name:  $
In particular, the line number, release number, and file name are all filled in automatically.



Subsections
next up previous contents
Next: Reporting Errors In GRASP Up: GRASP Routines: General purpose Previous: GRASP Routines: General purpose   Contents
Bruce Allen 2000-11-19