# dispApiError

Called by service API functions on errors to invoke a user-defined error handler, log a trace message, and return the error code.

#### Prototype

DWORD dispApiError (CTAHD ctahd, DWORD errcode, const char *func, const char *info)

Argument | Description
ctahd | Context handle.
errcode | Error code returned by API function.
func | Pointer to the name of the API function reporting the error.
info | Pointer to the character string with additional information about the error.

#### Return values

This function returns the return value of the application-supplied error handler, or errcode if there is no handler.

#### Details

dispApiError is usually called when returning an error from an API function call by using the CTAAPIERROR macro or the CTAAPIERRORINFO macro. It returns the error code passed in as an argument so it can be called in a function return statement.

If tracing is enabled and either the application specified CTA_EXIT_ON_ERRORS or CTA_REPORT_ERRORS as the error handler, or the global or context specific trace mask has the CTA_TRACEMASK_API_ERRORS bit set, dispApiError logs a trace record to ctdaemon.

The Natural Access error macros, CTAAPIERRORINFO and CTAAPIERROR, are defined in ctadisp.h.

#### See also

dispError, dispLogTrace