Error handling functions for the HLU library.
#include <ncarg/hlu/hlu.h> const char *NhlPError( NhlErrorTypes severity, int errnum, char *format, ... ) void NHLPERROR(( NhlErrorTypes severity, int errnum, char *format, ... )) int NhlErrGetId() int NhlErrNumMsgs() NhlErrorTypes NhlErrGetMsg( int msgnum, const NhlErrMsg **msgptr ) NhlErrorTypes NhlErrClearMsgs() NhlErrorTypes NhlErrAddTable( int start, int tlen, const char **etable ) char *NhlErrSPrintMsg( char *buffer, const NhlErrMsg *msg ) const char *NhlErrFPrintMsg( FILE *fp, const NhlErrMsg *msg )
subroutine NhlFPError(severity, errnum, message) character*(*) severity, message integer errnum subroutine NhlFErrGetId(id_ret) integer id_ret subroutine NhlFErrNumMsgs(nummsg) integer nummsg subroutine NhlFErrGetMsg(msgnum, sev, emsg, errorno, sysmsg + line, fname, ierr) integer msgnum, sev, errorno, line, ierr character*(*) emsg, sysmsg, fname subroutine NhlFErrClearMsgs(ierr) integer ierr subroutine NhlFErrSprintMsg(buffer, msgnum) character*(*) buffer integer imsg subroutine NhlFErrFprintMsg(iunit, msgnum) integer iunit, imsg
Type name: NhlTErrorTypes Definition: typedef enum _NhlErrType{ NhlFATAL = -4, /* "FATAL" */ NhlWARNING = -3, /* "WARNING" */ NhlINFO = -2, /* "INFO" */ NhlNOERROR = -1 /* "NOERROR" */ } NhlErrorTypes;
Type name: <none> typedef struct _NhlErrMsg{ NhlErrorTypes severity; char *msg; int errorno; const char *sysmsg; int line; char *fname; } NhlErrMsg, *NhlErrMsgList;
The NhlPError function is used to report errors to the error module. The fmt and arg parameters are parsed in the same way as printf parses its arguments. The NHLPERROR macro is used in the same way as the NhlPError function except that it prepends File and Line information to the error message. Notice the double parentheses, this was necessary to get the macro to take variable number arguments.
Another function that is useful to programmers--if they plan to use the NhlPError function to report errors--is NhlErrAddTable. This function allows the programmer to add an additional error table in the same format as the system error table. The values 0 - 1000 are reserved for the system error table. The error module will not allow overlapping error tables to be installed.
The error module was implemented as another object in the Nhl library. This is important because all configuration of the Error module is done by setting resources in this object. The NhlOpen function creates the Error object so the resources are not available to the programmer at create time, except by using a resource file. However the programmer does have NhlSetValues and NhlGetValues access. The NhlErrGetId function is provided so the programmer can get the Id that is necessary to set or get resources in an object.
The rest of the functions are provided to allow the programmer to do as much of the error handling as they want. They are really only useful if the error object's NhlNbufferErrors resource is set to True.
The NhlErrNumMsgs function is provided so the programmer can query the error object to find out how many error messages it currently has buffered. The NhlErrGetMsg function is used to retrieve a pointer to the error message indexed by msgnum. The error message is saved internally in a NhlErrMsg structure. The index is from 1 to NhlErrNumMsgs.
The NhlErrClearMsgs function is used to clear the Error object's internal message buffer. The NhlErrFPrintMsg and NhlErrSPrintMsg functions were provided so the programmer can print messages in the NhlErrMsg structure format in the same way the error object prints them out internally.
The error object is destroyed when the NhlClose function is called. The programmer can use the NhlPError function when the error object doesn't exist (before NhlOpen or after NhlClose). However, all messages are printed to stderr because no configuration is possible.
const char*
that points to the formatted error message.
The NHLPERROR macro does not return a value.
The NhlErrGetId function returns an int that is a unique id for the Error object.
The NhlErrNumMsgs function returns an int that is the number of error messages that have been buffered in the Error object.
The NhlErrGetMsg, NhlErrClearMsgs, and NhlErrAddTable functions return values of type NhlErrorTypes. These error eunctions return NOERROR if they were able to complete the function, and FATAL otherwise.
The NhlErrSPrintMsg function returns a pointer to the buffer provided, or NULL on error.
The NhlErrFPrintMsg function returns a pointer to a
const char
buffer that contains the formatted string that was
printed to the fp argument, or NULL on error.
NG4.1 Home, Index, Examples, Glossary, Feedback, Ref Contents, Ref WhereAmI?