BEA Logo BEA Tuxedo Release 7.1

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   Tuxedo Doc Home   |   Programming   |   Topic List   |   Previous   |   Next   |   Contents

   Programming a BEA Tuxedo Application Using TxRPC

Handling Status and Exception Returns

In the X/OPEN RPC specification, non-application errors are returned via status parameters or a status return. A fault_status value is returned if there is an RPC server failure and a comm_status value is returned if there is a communications failure. Status returns are specified by defining an operation return value or an [out] parameter of type error_status_t in the IDL file, and declaring the same operation or parameter to have the [fault_status] and/or [comm_status] attribute in the ACF file.

For example, an operation defined in an IDL file as:

error_status_t op([in,out]long *parm1, [out]error_status_t *commstat);

with a definition in the corresponding ACF file as:

[fault_status]op([comm_status]commstat);

returns an error from the server via the operation return, and an error in communications via the second parameter. Its use in the client code could be as follows:

if (op(&parm1, &commstat) != 0 || commstat != 0) /* handle error */

The advantage of using status returns is that the error can be handled immediately at the point of failure for fine-grained error recovery.

The disadvantage of using status returns is that the remote function has additional parameters that the local version of the function does not have. Additionally, fine-grained error recovery can be tedious and error prone (for example, some cases may be missing).

DCE defines a second mechanism called exception handling. It is similar to C++ exception handling.

The application delimits a block of C or C++ code in which an exception may be raised with the TRY, CATCH, CATCH_ALL, and ENDTRY statements. TRY indicates the beginning of the block. CATCH is used to indicate an exception-handling block for a specific exception, and CATCH_ALL is used to handle any exceptions for which there is not a CATCH statement. ENDTRY ends the block. TRY blocks are nested such that if an exception cannot be handled at a lower level, the exception can be raised to a higher level block using the RERAISE statement. If an exception is raised out of any exception handling block, the program writes a message to the log and exits. Details of the exception handling macros and an example are described in TRY(3c) in the BEA Tuxedo C Function Reference.

In addition to exceptions generated by the communications and server for an RPC call, exceptions are also generated for lower level exceptions, specifically operating system signals. These exceptions are documented within TRY(3c) in the BEA Tuxedo C Function Reference.