Bioplib
Protein Structure C Library
|
Build and print an error stack for program failure. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SysDefs.h"
#include "macros.h"
#include "ErrStack.h"
Go to the source code of this file.
Data Structures | |
struct | _errorstack |
Typedefs | |
typedef struct _errorstack | ERRORSTACK |
Functions | |
void | blStoreError (char *routine, char *error) |
void | blShowErrors (void *PrintRoutine(char *), BOOL Trace) |
Build and print an error stack for program failure.
This code is NOT IN THE PUBLIC DOMAIN, but it may be copied according to the conditions laid out in the accompanying file COPYING.DOC.
The code may be modified as required, but any modifications must be documented so that the person responsible can be identified.
The code may not be sold commercially or included as part of a commercial product except as described in the file COPYING.DOC.
This set of routines allows a stack of errors to be created. When a program has a fatal error, the StoreError() routine is called to place the error on the stack. As the program un-winds, each routine which fails stores it's error. Finally, before the program actually exits, it calls ShowErrors() to display the error stack.
blStoreError(char *routine, char *error)
The routine is called with the name of the routine at fault and the description of the fault.
blShowErrors(void *PrintRoutine, BOOL Trace)
The routine is called with a pointer to the routine which is to do the actual error display and a flag to indicate whether the faulty routine names should be displyed. This is only of use if the user has access to the source code so should be used for debugging purposes only.
If PrintRoutine is supplied as NULL, the simple PrintAnError() routine will be used which displays the error on stderr. More complex routines could, for example, show the error in a requester or output to a window.
If a print routine is specified, the routine is called with:
blShowErrors(void *)MyRoutine, TRUE);
Definition in file ErrStack.c.
typedef struct _errorstack ERRORSTACK |
void blShowErrors | ( | void * | PrintRoutinechar *, |
BOOL | Trace | ||
) |
[in] | *PrintRoutine | The print routine or NULL |
[in] | Trace | Flag to print routine names |
Display the error stack using the supplied print routine or the simple default one if NULL is given.
Definition at line 182 of file ErrStack.c.
void blStoreError | ( | char * | routine, |
char * | error | ||
) |
[in] | *routine | Name of the routine generating the error |
[in] | *error | Description of the error |
Stores an error on the error stack.
Definition at line 137 of file ErrStack.c.