app_error()

Purpose

User-defined function to over-ride standard handling of DP4 system errors, FAIL errors. and other standard DP4 messages.

Syntax
void app_error(int DP4P flags,int DP4P type,int DP4P error_nr,
               int DP4P error0,int DP4P error1)
{
 /* Whatever code you like */
}
Parameters

int DP4P flags

if DP4ERR_REPORT is set then the error has not yet been reported by TRM and needs reporting. Clearing this flag stops the error message from being displayed or written to syslog.prn

if DP4ERR_HALT is set then the error is a system error or fail error and the program will terminate unless the flag is cleared

int DP4P type

ValueMeaning
1The message is a system message (from the SYSTEM mapset) but not an error. A typical message is the 'Log file nearly full' message
2The message is a system request (from the SYSTEM mapset) but not an error. A typical message is the 'Load log disk' message. With these messages the user is invited to press a key to continue. Pressing Enter continues the program normally. Pressing Esc will result in a call to dp4_halt().
3the message is a system error
4 the message is a fail error

int DP4P error

This is the number of the error message that should be displayed.

int DP4P error0
int DP4P error1

These are additional parameters giving further information about the error.

Description

Here is an example app_error() function:

void app_error(int DP4P flags,int DP4P type,int DP4P error_nr,
               int DP4P error0,int DP4P error1)
{
  if (*flags & DP4ERR_REPORT)
  {
    /* Report error ourself */
    printf("DP4 Error Type %d Number %d paras %d %d\r\n",type,error_nr,error0,error1);
    *flags &= ~DP4ERR_REPORT;
  }
  if (type == 3 && error_nr == 31) /* Database needs backup */
  {
    *flags &= ~DP4ERR_HALT;
    /* program will test return from db_open() and run back up code */
  }
}

The default app_error() function does nothing.