C API return codes

There are three types of C API return codes: success, warning, or error.

  • Success: The call succeeded. The only success code is MPIRC_SUCCESS.
  • Warning: The call succeeded, but some condition arose that might be of concern. For example, MPIRC_W_NO_DATA.
  • Error: The call failed.

The following return codes, which are defined in the dtxpi.h header file along with many others, should be used by an adapter.

Return code Description
MPIRC_SUCCESS This operation was successful.
MPIRC_W_NO_DATA The adapter has no data to return from a Get.
MPIRC_W_END_OF_DATA All data has been retrieved from the input.
MPIRC_E_BAD_CONNECTION The connection became unusable.
In addition to predefined codes, an adapter might provide its own return codes. Error and warning codes returned should be defined using the following macros:
  • MAKEUSERWARNING(code) - sets the code as a warning code
  • MAKEUSERERROR(code) - sets the code as an error code
Example
#define MY_E_CONNECT_FAILED 
MAKEUSERERROR(1)

#define MY_E_BAD_PARMS 
MAKEUSERERROR(2)

#define MY_E_NO_MEMORY 
MAKEUSERERROR(3)

#define MY_W_NO_MSG_AVAIL 
MAKEUSERWARNING(1)

#define MY_W_TIMED_OUT 
MAKEUSERWARNING(2)

Zero (0) should not be used as the parameter of MAKEUSERERROR or MAKEUSERWARNING.

These codes must then be returned as properties of the object.

Example
mpiPropertySetInteger(hAdapter,
MPIP_OBJECT_ERROR_CODE, 0, rc);

Return codes from the resource to which the adapter connects might also be returned, (for example, a SQL State or code from an R/3 API) by settingthe MPIP_ADAPTER_PROVIDER_CODE property. The return code from the adapter methods determines program flow. If an error occurs in an adapter method, an error code must be returned in the return code. The MPIP_OBJECT_ERROR_CODE property does not determine flow, but is used to maintain error information related to various objects. This information can then be displayed in the trace and audit logs.