Name
XtErrorMsgHandler — prototype for high-level error and warning handlers.
Synopsis
typedef void (∗XtErrorMsgHandler)(String, String, String, String, String ∗, Cardinal ∗);
String name;
String type;
String class;
String defaultp;
String ∗params;
Cardinal ∗num_params;
Arguments
nameSpecifies the name that is concatenated with the specified type to form the resource name of the error message.
typeSpecifies the type that is concatenated with the name to form the resource name of the error message.
classSpecifies the resource class of the error message.
defaultpSpecifies the default message to use if no error database entry is found.
paramsSpecifies a pointer to a list of values to be substituted in the message.
num_params
Specifies the number of values in the parameter list.
Description
Application-supplied error handling functions, for both warnings and fatal errors, are of type XtErrorMsgHandler. These functions can be set with XtAppSetErrorMsgHandler and XtAppSetWarningMsgHandler.
The specified name can be a general kind of error, like invalidParameters or invalidWindow, and the specified type gives extra information. Standard printf notation is used to substitute the parameters into the message.
The default Toolkit-supplied error and warning handler functions construct a string and pass the result to XtError and XtWarning, respectively. Low-level handlers are of type XtErrorHandler.
The error handler should make a call to XtGetErrorDatabase or XtAppGetErrorDatabase to retrieve the address of the loaded error database (if a database other than the default is being used), and XtGetErrorDatabaseText or XtAppGetErrorDatabaseText to actually retrieve the message from the database.
Examples
The example below shows the default error message handler from the MIT R4 Intrinsics.
static void _XtDefaultErrorMsg
(name,type,class,defaultp,params,num_params)
String name,type,class,defaultp;
String∗ params;
Cardinal∗ num_params;
{
char buffer[1000], message[1000];
XtGetErrorDatabaseText(name,type,class,defaultp, buffer, 1000);
if (params == NULL || num_params == NULL || ∗num_params == 0)
XtError(buffer);
else {
int i = ∗num_params;
String par[10];
if (i > 10)
i = 10;
bcopy( (char∗)params, (char∗)par, i ∗ sizeof(String) );
bzero( &par[i], (10-i) ∗ sizeof(String) );
(void) sprintf(message, buffer, par[0], par[1], par[2], par[3],
par[4], par[5], par[6], par[7], par[8], par[9]);
XtError(message);
if (i != ∗num_params)
XtWarning( "some arguments in previous message were lost");
}
}