ChiMu  
 
Menu Edge About   Products   Services   Projects   Publications  
  Publications > Kernel Frameworks      Previous Page Previous TOC Next Next Page

Exceptions

Development Exceptions ThrowableWrapper and WrappedExceptions

Kernel Exceptions adds a few useful exception subclasses to the standard Java Exception classes. These are currently all development exceptions.

Development Exceptions

DevelopmentExceptions are errors that occur at Runtime but are caused solely by a malformed program. The following table documents some of the current Development exceptions, and gives a feel for what the other ones would be like.

NotImplementYetException

Used to express that some functionality is planned but not implemented

ShouldNotImplementException

A subclass has a more restrictive interface than it "claims" to have (by inheritance or type implementation) and should not (or at least does not) implement a particular method.

FailedRequireException

A method requires (in the Eiffel sense) something from the caller (e.g. non-null parameters or being in a certain state) which was not satisfied

ThrowableWrapper and WrappedExceptions

ThrowableWrappers enable you to throw a new exception that wraps another exception, usually the exception that you are currently handling. Although most clients will only "see" the newly thrown exception, other clients (and the #toString and #printStackTrace methods) can look into what other exception lower in the system caused the current exception. This structure allows you to produce high-level exceptions but still enable a client to see the details of a low level exception.

ThrowableWrapper is the interface for wrapped exceptions. If you want to test whether a given exception may be wrapping another exception, test whether it is an instanceof (implements) ThrowableWrapper. Then you can ask what the wrappedThrowable was (which could be null for an originating exception) and continue the process through the next exception, if any.

WrappedException and RuntimeWrappedException are two implementation classes that can either be used directly or subclassed.

 
Publications > Kernel Frameworks Previous Page Previous TOC Next Next Page