Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX -
Contents Index PreviousNext

Part 2 Developing Applications by APIs> Chapter 11 Developing C Applications> 11.2 How to Use C APIs

11.2.5 Error Handling

If a warning or error occurs while a C API is being used, a value other than that indicating normal completion will be returned when a function is executed. In such cases, the ShunGetErrorMessage function can be used to obtain the following information:

mark1Sample Code

if(ret != SHUN_SUCCESS) {
  /* Obtain error information */
  ShunGetErrorMessage(StmtH, &Err_Level, &Err_Msg);               (1) (2)
  switch ( Err_Level ) {
  case SHUN_ERROR_CONNECTION:
    printf("Error level            = SHUN_ERROR_CONNECTION\n");
    break;
  case SHUN_ERROR_TRANSACTION:
    printf("Error level            = SHUN_ERROR_TRANSACTION\n");
    break;
  case SHUN_ERROR_DATA:
    printf("Error level            = SHUN_ERROR_DATA\n");
    break;
  }
  printf("Error message          = %s\n", Err_Msg);
}

mark1Obtain Error Information

Use the values returned when each function is executed to determine if an error has occurred. If an error has occurred, obtain the error information.

mark2(1) Error Level

By examining the error level, the user can ascertain the status of an application after an error has occurred.

The following four error levels are returned:

Constant

Meaning

SHUN_INFORMATION

Indicates normal completion.

SHUN_ERROR_DATA

Indicates that a warning level error (such as a parameter error) has occurred. Retry from the point where the error occurred.

SHUN_ERROR_TRANSACTION

An error has caused a transaction to be canceled. Re-execute the process from the start of the transaction.

SHUN_ERROR_CONNECTION

An error has occurred, causing the connection to Shunsaku to be forcibly closed. Discard and then recreate the connection handle where the error occurred, and then re-execute the process starting from establishing the connection.

mark2(2) Error Message

Refer to Messages Output when APIs are Executed in the Messages for more information on error messages.


Down11.2.5.1 An Example of Error Handling

Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006