DMERROR(5ICD)

NAME
dmError, dmPerror - DDM error message functions

SYNOPSIS

#include "dmincl.h"
dmError (s)
char *s;
dmPerror (s)
char *s;

PARAMETERS
specifies the name of the program that generated the error, or the argument of a DDM function to which the error message applies.

DESCRIPTION
Function dmPerror() produces a short error message on stderr output describing the last error encountered during a call to the DDM system function from an application program. First the argument string s is printed, then a colon, then the message and a newline. The error number is taken from the external variable dmerrno (see dmintro(5ICD), which is set when errors occur but not cleared when non-erroneous calls are made.

To simplify variant formatting of messages, the vector of message strings dmerrlist[] is provided; External variable dmerrno can be used as an index in this table to get the corresponding message string without the newline. Variable dmerrno may not be greater than dmnerr, which is set to the number of messages provided for the table. The external variable dmnerr should be checked because new error codes may be added to the DDM system before they are added to the table.

Function dmError() is called by the Interface Functions itself, when they detect an error, i.e. when they actually set dmerrno. The function dmError() will then call dmPerror(), to produce the corresponding message automatically on stderr output. This is to simplify the error handling of the application program. In case the application wants to provide the error messages itself, the application programmer must provide his own (possibly dummy-) dmError() function. For example, you might want to display the errors in a special window on your graphics device.

To show how the error messages are handled, here follows the source code listings of the functions dmError() and dmPerror().
#include "stdio.h"
#include "dmincl.h"
dmError (s)
char   *s;
{
    dmPerror (s);
}
dmPerror (s)
char   *s;
{
    if (s && *s != '\0')
        fprintf (stderr, "%s: ", s);
    if (dmerrno > 0 && dmerrno <= dmnerr)
        fprintf (stderr, "%s\n", dmerrlist[dmerrno]);
    else
        fprintf (stderr, "DDM error number: %d\n", dmerrno);
}

SEE ALSO
dmintro(5ICD).