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 10 Developing .NET Applications> 10.3 How to Use .NET APIs

10.3.5 Error Handling

The exceptions in .NET API are different depended on the error that has occurred. Users will be able to process each exception that has been catched separately. There are two types of exceptions in .NET API, the exceptions from .NET API and the general exceptions. The following diagram and table explain the inheritance relationship of exception classes in .NET API and the meaning of each exception.

[Figure 10-16 Inheritance Relationship of Exception Classes in .NET API]

[Table 10-26 List of Exceptions for .NET API]

Exception

Meaning

ShunException

This class is the base class for all exception classes in Shunsaku.

Use for catching all Shunsaku errors.

ShunConnectionTerminatedException

The exception thrown when the connection to Shunsaku is closed forcibly. Re-execute the process starting from establishing the connection.

ShunTimeoutException

The exception thrown when the connection to Shunsaku is closed forcibly due to the timeout. Re-execute the process starting from establishing the connection.

ShunTransactionRolledbackException

The exception thrown when the transaction is cancelled. Re-execute the process from the start of the transaction.

ShunContinuousException

The exception thrown when the warning level error occurs. Eliminate the cause of the error, and then re-execute the process from the point where the error occurred.

ShunAPIConfigException

The exception thrown when the API environment file is error. Eliminate the cause of the error, and then re-execute the process.

ShunSystemException

The exception thown when unpredictable errors occur. Obtain the error message and contact Fujitsu's system engineers.

Refer to the .NET API Reference for more information on the exceptions from each method.

mark1Sample Code for C# .NET

try {
  :
}
catch ( ShunContinuousException e ) {
  // The coding for ShunContinuousException
  try {
    if ( service != null ) {
      if ( service.State == ShunConnectionState.Open ) {
        if ( !service.AutoCommit ) { service.Rollback(); }
        service.Disconnect();
      }
    }
  }
  catch( ShunException ex ) {
    Console.WriteLine( "Error message: " + ex.Message );               (1)
  }
  Console.WriteLine( "Error message: " + e.Message );
}
catch ( ShunTransactionRolledbackException e ) {
  // The coding for ShunTransactionRolledbackException
  try {
    if( service != null ) {
      if( service.State == ShunConnectionState.Open ) {
         service.Disconnect();
      }
    }
  }
  catch( ShunException ex ) {
    Console.WriteLine( "Error message: " + ex.Message );
  }
  Console.WriteLine( "Error message: " + e.Message );
}
catch (ShunConnectionTerminatedException e ) {
  // The coding for ShunConnectionTerminatedException
  Console.WriteLine( "Error message: " + e.Message );
}

mark1Sample Code for VB .NET

Try
  :
Catch e As ShunContinuousException
  ' The coding for ShunContinuousException
  Try
    If Not service Is Nothing Then
      If service.State = ShunConnectionState.Open Then
         If Not service.AutoCommit Then
           service.Rollback()
         End If
         service.Disconnect()
      End If
    End If
  Catch ex As ShunException
    Console.WriteLine( "Error message : " + ex.Message )               (1)
  End Try
  Console.WriteLine( "Error message : " + e.Message )

Catch e As ShunTransactionRolledbackException
  ' The coding for ShunTransactionRolledbackException
  Try
    If Not service Is Nothing Then
      If service.State = ShunConnectionState.Open Then
         service.Disconnect()
      End If
    End If
  Catch ex As ShunException
    Console.WriteLine( "Error message : " + ex.Message )
  End Try
  Console.WriteLine( "Error message : " + e.Message )

Catch e As ShunConnectionTerminatedException
  ' The coding for ShunConnectionTerminatedException
  Console.WriteLine( "Error message : " + e.Message )

End Try

mark2(1) Error Message

The Message property can be used to obtain the error message.

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


Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006