CORBA exceptions: Catching

You must handle exceptions in client programs. Remember that any method might throw a standard exception. Therefore, an exception can be thrown by these methods at any time - even if there are no exceptions declared in the raises clause of that method. The default behavior for uncaught exceptions is to end that process. If this happens, suspect an uncaught exception first. The exact style of how or what exceptions are caught depends on what the client application does for error recovery. However, the following is a list of some general rules:

The following is a simple client code example:

try
{
   // Some real code goes here
   foo.boo();
}
// Catch any specific User exceptions defined for the method in the
// `raises' clause
catch (IManagedClient::INoObjectWKey  nowk)
{
   // Process the error, more specific recovery could be made here
   // because the specific error is known
}
// Catch and process any other specific User exceptions
...
// Catch any other User exceptions defined for the method in the
// `raises' clause
catch (CORBA::UserException  ue)
{
   // Process any other User exceptions. Use the .id() method to
   // record or display useful information
   cout << "Caught a User Exception: " << ue.id() << endl;
}
// Catch any System exceptions defined for the method in the
// `raises' clause
catch (CORBA::SystemException  se)
{
   // Process any System exceptions. Use the .id(), and .minor()
   // methods to record or display useful information
   cout << "Caught a System Exception: " << ue.id() << ": " << 
        ue.minor() << endl;
}
catch (...)
{
   // Process any other exceptions. This would catch any other C++
   // exceptions and should probably never occur
   cout << "Caught an unknown Exception" << endl;
}

Specific standard exceptions cannot be caught individually. If processing individual standard exceptions is required, it can be done within the CORBA::SystemException catch block using the .id() method.


Related reference
CORBA exceptions



Searchable topic ID:   rcor_copcex
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/corba/ref/rcor_copcex.html

Library | Support | Terms of Use | Feedback