(Page 45 of 80 in this chapter)


adiSetErrorHandler

Description

Defines the action taken when errors are returned from AG Access functions.

Prototype

DWORD adiSetErrorHandler(
CTAERROR_HANDLER handler )

handler Pointer to an error-handling routine provided by the application.

Return Values

SUCCESS

Events

None.

Details

This function allows the application program to trap programming errors. If an error is encountered when executing a command, then AG Access performs the error action before returning to the application.

The error action is undertaken only when AG Access functions are invoked; it is not undertaken if an error is returned via an ADI_EVENT (see ADI_EVENT value field in adiFetchAndProcess).

By default, there is no error action. The application can specify any of the following error actions:

DWORD NMSSTDCALL yourhandler( CTAHD ctahd,
DWORD errcode,
char *errortext,
char *func )

ctahd Context incurring the error (this is the same ctahd that the application passed to the function experiencing the error).

errcode Error code as detected by AG Access

errortext Pointer to error textual description (see adiGetErrorText).

func Pointer to the function name in which the error occurred.

AG Access returns to the application whatever is returned from yourhandler. It is recommended that the errcode received is returned.

See Also

adiGetErrorText

Example


DWORD NMSSTDCALL myErrorHandler( CTAHD  ctahd, DWORD errorcode,
                                 char *errtxt, char *func )
{
    /* Just print out the error for debugging. */
    printf( "myErrorHandler: %s on ctahd=%#x, %s\n", errtxt, ctahd, func );
    return errorcode;                   /* pass along to application */
}


void mySetErrorHandler( void )
{
    adiSetErrorHandler( myErrorHandler );
}



(Page 45 of 80 in this chapter)


Tech_Support@nmss.com
Copyright © 1996, Natural MicroSystems, Inc. All rights reserved.