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 9 Developing Java Applications> 9.3 How to Use Java APIs

9.3.5 Error Handling

If an error occurs with an application that uses the Java APIs, a ShunException is thrown. The methods of the ShunException class can be used to obtain the following information:

mark1Sample Code

try {
    :
} catch (ShunException ex) {
     int errorLevel = ex.getErrLevel();                                (1)
     switch( errorLevel ) {
       case ShunException.SHUN_ERROR :
         System.out.println("Error level  :SHUN_ERROR");
         break;
       case ShunException.SHUN_ERROR_TRANSACTION_ROLLEDBACK :
         System.out.println("Error level  :SHUN_ERROR_TRANSACTION_ROLLEDBACK");
         break;
       case ShunException.SHUN_ERROR_CONNECTION_TERMINATED :
         System.out.println("Error level  :SHUN_ERROR_CONNECTION_TERMINATED");
         break;
     }
     System.out.println("Error message:" + ex.getMessage());           (2)
}

mark2(1) Error level

The error level can be obtained using the getErrLevel method.

When errors occur, the connection to Shunsaku is sometimes closed forcibly. Users can check the error level to find out the state of the application where the error occurred.

There are three error levels, as shown in the following table:

[Table 9-8 Error Levels]

Constant

Meaning

SHUN_ERROR

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

SHUN_ERROR_TRANSACTION_ROLLEDBACK

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

SHUN_ERROR_CONNECTION_TERMINATED

An error has caused the connection to be forcibly closed. Close the ShunConnection object where the error occurred and then re-execute the process starting from establishing the connection.

mark2(2) Error message

The error message can be obtained using the getMessage method.

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


Down9.3.5.1 An Example of Error Handling

Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006