org.lsst.ccs.utilities.exc
Class BundledException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.lsst.ccs.utilities.exc.BundledException
All Implemented Interfaces:
Serializable, ThrowableList

public class BundledException
extends Exception
implements ThrowableList

This is to create a Bundle of linked Exception : a code may not stop at the first Exception it catches but store the Exception in reverse order and then , when finished, throw a Set of Exception. Typical code could look like this:

      ThrowableList listExc = null
     for (Thing thing : things) {
         try {

         } catch(AnException exc) {
              // or use a specific subclass of BundledException
             listExc = new BundledException(exc, listExc)
     }
     if(listExc != null) {
         throw  listExc.current() ;
     }
 
Beware: do not confuse this with a "cause" (such as in getCause()).

The interface ThrowableList may help create list of throwables that do not necessarily extends BundledException. (this could have been implemented through multiple decorators ...)

Author:
bamade
See Also:
Serialized Form

Constructor Summary
BundledException(String s, ThrowableList previousThrowable)
           
BundledException(String s, Throwable throwable, ThrowableList previousThrowable)
           
BundledException(ThrowableList previousThrowable)
           
BundledException(Throwable throwable, ThrowableList previousThrowable)
           
 
Method Summary
 Throwable current()
           
 Throwable previous()
           
 String toString()
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BundledException

public BundledException(ThrowableList previousThrowable)

BundledException

public BundledException(String s,
                        ThrowableList previousThrowable)

BundledException

public BundledException(String s,
                        Throwable throwable,
                        ThrowableList previousThrowable)

BundledException

public BundledException(Throwable throwable,
                        ThrowableList previousThrowable)
Method Detail

previous

public Throwable previous()
Specified by:
previous in interface ThrowableList

current

public Throwable current()
Specified by:
current in interface ThrowableList

toString

public String toString()
Overrides:
toString in class Throwable


Copyright © 2013 LSST. All Rights Reserved.