Last Modified: May 23, 2004
Version: 1.6
<Ken Cavanaugh>The PEORB already has extensive exception handling code for CORBA system exceptions. The mechanism starts with a descriptive .mc file, with data stored in S-expressions. This takes the following form:
("packagename" "classname" group ( (EXCEPTIONCLASS (EXCEPTION_NAME ID LEVEL "meaning with {n] args") ... ) ... ) )
Here the packagename is the Java package in which the classname is generated. The group is used to group CORBA system exception into different groups. This is followed by a list of exception classes (given by just the major exception type in the CORBA system exceptionc case). Each exception class in turn lists the EXCEPTION_NAME which is used as a constant for the minor code, and also as exceptionName for the name of the method used to create and log the exception. The ID is used to create a unique log record ID for this log record. The meaning string provides a way to parameterize the string that describes the log entry in the logger.
The basic idea here is to generate a Java class for each such file that contains methods for each EXCEPTION_NAME entry called exceptionName. Each exceptionName method does two things: first, it logs all details about the exception, then it creates an instance of the exception and returns it. The caller may then throw the exception, store for later use, or ignore it as needed.
We can use almost the same structure to handle arbitrary exceptions. Here is a slight variation:
("packagename" "classname" group ( (ExceptionClass (exceptionName ID LEVEL "meaning with {n] args") ... ) ... ) )
We should make some simplifying assumptions to handle this case.
We also need to handle message strings that contain Cases: FooException( String reason ) BarException( int data, Object more ) BarException( String reason, int data, Object more ) - If first param is a string, it is a reason string - All additional constructor args are {1}, ... {n} - If message string contains {m}, m>n, then additional string args are supplied in the methods - reason string is set to the formatted message