Handling CORBA exceptions
CORBA provides a standard way for components to indicate errors
or warnings. CORBA supports two types of exceptions:
-
System exceptions
-
User-defined exceptions
A system exception is one of a standard set of errors raised
by the server. These exceptions are defined in the CORBA specification.
A user-defined exception is an error or warning defined in
the component’s IDL. A user exception is a new datatype
that describes a set of data elements that are returned to the client
when the exception is raised.
System exceptions
In PowerBuilder, CORBA system exceptions are mapped to a set
of objects that inherit from the RuntimeError object. To see a list
of these exceptions, select CORBASystemException on the System tab
in the PowerBuilder Browser, select ShowHierarchy from the pop-up
menu, and expand the Treeview item.
The names of the CORBASystemException objects in PowerBuilder
map to the names of CORBA system exceptions as defined in the CORBA/IIOP Specification
with underscore characters omitted. For example, the PowerBuilder
CORBACommFailure exception maps to the CORBA_COMM_FAILURE
exception. For detailed information about CORBA exceptions, see
the CORBA/IIOP Specification, which can be downloaded from
the OMG Web site
.
You might want to provide error handling for the following
exceptions when you invoke methods on a component:
|
1 |
TRY<br>... // invoke methods<br>CATCH (corbacommfailure cf)<br>... // A component aborted the EAServer transaction,<br>    // or the transaction timed out. Retry the<br>    // transaction if desired.<br>CATCH (corbatransactionrolledback tr)<br>... // possibly retry the transaction<br>CATCH (corbaobjectnotexist one)<br>... // Received when trying to instantiate<br>    // a component that does not exist. Also <br>    // received when invoking a method if the <br>    // object reference has expired<br>    // (this can happen if the component<br>    // is stateful and is configured with<br>    // a finite Instance Timeout property).<br>    // Create a new proxy instance if desired.}<br>CATCH (corbanopermission np)<br>... // tell the user they are not authorized<br>CATCH (corbasystemexception se)<br>... // report the error but don't bother retrying<br>FINALLY<br>    // put cleanup code here<br>END TRY |
User-defined exceptions
User-defined exceptions are mapped to the CORBAUserException
object, which inherits from the Exception object. PowerBuilder clients
can handle exceptions thrown by any component type.
If an EAServer component
has a method on it that is defined to throw an exception, that method
on the PowerBuilder proxy object is also declared to throw a user-defined
exception. The definition of the user-defined exception is created
when you create the component proxy.
CORBA does not support exception hierarchies
Exception hierarchies are not supported in the CORBA IDL.
As a result, when you generate proxies for a server component that
has an inherited exception, the generated proxies all inherit directly
from CORBAUserException.
All Create, Remove,
and FindByPrimaryKey methods on EJB components throw
the EJB CreateException, RemoveException, and FinderException exceptions.
These exceptions are represented by IDL exceptions with the same name
in the CtsComponents package in EAServer.