Specifications
Error Handling
3-17
3
Example 3-4 A Simple Error Handler
IPLStatus ownError(IPLStatus status, const char *func,
const char *context, const char *file, int line);
{
fprintf(stderr, "IPL Library error: %s, ", iplErrorStr(status));
fprintf(stderr, "function %s, ", func ? func : "<unknown>");
if (line > 0) fprintf(stderr, "line %d, ", line);
if (file != NULL) fprintf(stderr, "file %s, ", file);
if (context) fprintf(stderr, "context %s\n", context);
IplSetErrStatus(status);
exit(1);
}
main () {
extern IPLErrorCallBack ownError;
/* Redirect errors to your own error handler */
iplRedirectError( ownError);
/* Redirect errors back to the default error handler */
iplRedirectError(NULL);
}