### 2.3.4. Error Handling Routines

The first error handling routine allows the programmer to define an error callback function that is called when a fatal error is generated by the API or explicitly by the programmers code.

The second routine performs a method for clean termination of the program, shutting down the program and communication with ANSYS CFX.

#### 2.3.4.1. cfxImportError

    void cfxImportError (callback)
    void (*callback)(char *errmsg);

Define a user routine to be called before terminating due to a fatal error. `callback` is the application-supplied function to be called in the case of an error. The callback routine takes a single argument, `errmsg`, which will be passed by `cfxImportFatal` and should be processed by the callback function as a brief message describing the error that has occurred. If this function is not called or callback is not specified, then the normal termination behavior of the mesh import API will be that the any fatal errors will write the error message to `stderr` as well as being sent to CFX.

#### 2.3.4.2. cfxImportFatal

    void cfxImportFatal (errmsg)
    char *errmsg;

Terminate with an error message, `errmsg`. This routine will send the message to CFX, shut down the communication channel or test file and call the user callback function (if specified by a call to cfxImportError).

There is no return from this call. The import program will terminate immediately after clean up tasks have been performed.

Release 18.2 - © ANSYS, Inc. All rights reserved.