Handling CORBA exceptions

CORBA provides a standard way for components to indicate errors or warnings. CORBA supports two types of 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:

TRY
... // invoke methods
CATCH (corbacommfailure cf)
... // A component aborted the EAServer transaction,
    // or the transaction timed out. Retry the
    // transaction if desired.
CATCH (corbatransactionrolledback tr)
... // possibly retry the transaction
CATCH (corbaobjectnotexist one)
... // Received when trying to instantiate
    // a component that does not exist. Also 
    // received when invoking a method if the 
    // object reference has expired
    // (this can happen if the component
    // is stateful and is configured with
    // a finite Instance Timeout property).
    // Create a new proxy instance if desired.}
CATCH (corbanopermission np)
... // tell the user they are not authorized
CATCH (corbasystemexception se)
... // report the error but don't bother retrying
FINALLY
    // put cleanup code here
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.

NoteCORBA 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.