Boolean error handling

By convention, z/TPF API return codes indicate successful or unsuccessful completion by returning positive or zero values, respectively. This convention is violated somewhat by z/TPFCS API functions returning positive or zero values for true or false results, respectively.

To distinguish an unsuccessful API return code from a Boolean zero result, use the TO2_getErrorCode function call for error value retrieval. A zero error code value indicates a successful return of TO2_IS_FALSE while a nonzero error code value indicates an error return from the Boolean API function.

The following logic might be used in an application program to test for an error on a Boolean function:
  1. Call a Boolean z/TPFCS API; for example:
    TO2_isEmpty

    If a value of TO2_ERROR (0) is returned, this indicates that either an error has occurred or a value of TO2_IS_FALSE has been returned. If a value of TO2_IS_TRUE is returned, this indicates that no error has occurred.

  2. Call the following z/TPFCS API to retrieve the error code value:
    TO2_getErrorCode

    If a value of TO2_IS_FALSE (0) is returned, this indicates that no error has occurred. All other values returned from TO2_getErrorCode indicate the error that occurred.

  3. If an error has occurred, you can optionally call the following z/TPFCS API to retrieve the error code message text for the returned value:
    TO2_getErrorText