User-defined exceptions are defined in the component’s IDL definition. For example, you might define OverdrawnException to be thrown by methods that withdraw money from a bank account. In Java, all user-defined exceptions extend org.omg.CORBA.UserException.
In Java, IDL user-defined exceptions are checked exceptions; if the IDL definition of a method contains a raises clause, the equivalent Java stub method will have a throws clause that lists the equivalent Java exceptions. For example, consider the IDL definition below:
module MyModule { 
   exception MyException 
   { 
      string reason; 
   }; 
   interface MyIntf { 
      boolean throwException 
      ( in boolean yes_no ) 
      raises (MyException); 
   }; 
}; 
The equivalent Java throwException method is:
boolean throwException (boolean yes_no) throws MyModule.MyException;
As per the CORBA specification, methods defined on exceptions
cannot be marshalled to the client; that is, information provided
with an exception must be in a public variable.
| Copyright © 2005. Sybase Inc. All rights reserved. | 
 
 | 
|