Microsoft RPC uses the same approach to exception handling as the Microsoft Win32 API.
With Microsoft Windows NT and Windows 95, the RpcTryFinally / RpcFinally / RpcEndFinally structure is equivalent to the Win32 try-finally statement. The RPC exception construct RpcTryExcept / RpcExcept / RpcEndExcept is equivalent to the Win32 try-except statement.
The exception-handler structures in Microsoft RPC are provided so they can also be supported on computers with MS-DOS and Windows 3.x. When you use the RPC exception handlers, your client-side source code is portable to Windows NT, Windows 95, Windows 3.x, and MS-DOS. The different RPC header files provided for each platform resolve the RpcTry and RpcExcept structures for each platform. In the Win32 environment, these macros map directly to the Win32 try-finally and try-except statements. In other environments, these macros map to other platform-specific implementations of exception handlers.
The RPC exception-handling macros provide consistent try-except support across MS-DOS, Windows 3.x, Windows 95, and Windows NT. With Windows NT and Windows 95, RPC try-except support expands into Win32 try-except support.
When you write distributed applications for Windows NT and Windows 95 only, use the Win32 try-except and try-finally statements. If you are writing for MS-DOS and Windows 3.x, use the RPC versions of these macros. Potential exceptions raised by these structures include the set of error codes returned by the RPC functions with the prefixes "RPC_S_" and "RPC_X" and the set of exceptions returned by Win32.
Exceptions that occur in the server application, server stub, and server run-time library (above the transport layer) are propagated to the client. This propagation feature includes multiple layers of callbacks. No exceptions are propagated from the server transport level. The following figure shows how exceptions are returned from the server to the client.
The RPC exception handlers differ slightly from the OSF-DCE exception-handling macros TRY, FINALLY, and CATCH. Various vendors provide include files that map the OSF-DCE RPC functions to the Microsoft RPC functions, including TRY, CATCH, CATCH_ALL, and ENDTRY. These header files also map the RPC_S_* error codes onto the OSF-DCE exception counterparts, rpc_s_*, and map RPC_X_* error codes to rpc_x_*. For OSF-DCE portability, use these include files.
For more information about the RPC exception handlers, see RpcExcept and RpcFinally. For more information about the Win32 exception handlers, see your Win32 API documentation.