com.arsdigita.util
Class UncheckedWrapperException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byjava.lang.RuntimeException
              extended bycom.arsdigita.util.UncheckedWrapperException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CategorizationException, ConversionException, Encoding.UnsupportedException, FormNotFoundException, InitializationException, PersistenceException, VersioningException, WrappedTransformerException

public class UncheckedWrapperException
extends RuntimeException

A wrapper exception that can be used to rethrow another exception. TODO: This should become a skeleton when/if we switch to Java 1.4. http://java.sun.com/j2se/1.4/docs/guide/lang/chained-exceptions.html The basic exception methods are overridden with methods that combine this wrapper and its root cause, so it can be treated just like any normal exception in actual use. Note that it is not necessary to provide a string along with a root cause; in particular, the following usage: new UncheckedWrapperException(e); is more correct than new UncheckedWrapperException(e.getMessage(), e);

Version:
$Id: //core-platform/dev/src/com/arsdigita/util/UncheckedWrapperException.java#10 $
Author:
David Eison
See Also:
Serialized Form

Field Summary
static String versionId
           
 
Constructor Summary
UncheckedWrapperException(String msg)
          Constructor which only takes a msg, which will cause this UncheckedWrapperException to behave like a normal RuntimeException.
UncheckedWrapperException(String s, Throwable rootCause)
          Constructor which takes a message string and a root cause that this exception will be wrapping.
UncheckedWrapperException(Throwable rootCause)
          Constructor which takes a root cause that this exception will be wrapping.
 
Method Summary
 String getMessage()
          This exception's message and the root cause's.
 Throwable getRootCause()
          Gets the root cause of this exception.
 boolean hasRootCause()
          Indicates if this exception has a root cause.
 void printStackTrace()
          Stack trace for the root cause.
 void printStackTrace(PrintStream s)
          Stack trace for the root cause.
 void printStackTrace(PrintWriter s)
          Stack trace for the root cause.
static void throwLoggedException(Class source, String msg, Throwable rootCause)
          Throws an UncheckedWrapperException, and ensurs that it is logged at ERROR priority.
 String toString()
          Get a string representing this exception and the root cause.
 String toString(Class delegatingClass)
          Get a string representing this exception and the root cause.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

UncheckedWrapperException

public UncheckedWrapperException(String msg)
Constructor which only takes a msg, which will cause this UncheckedWrapperException to behave like a normal RuntimeException. While it doesn't seem to make a lot of sense to have a wrapper exception that doesn't wrap anything, this is needed so that it can be used as a direct replacement for RuntimeException.


UncheckedWrapperException

public UncheckedWrapperException(Throwable rootCause)
Constructor which takes a root cause that this exception will be wrapping.


UncheckedWrapperException

public UncheckedWrapperException(String s,
                                 Throwable rootCause)
Constructor which takes a message string and a root cause that this exception will be wrapping. The message string should be something different than rootCause.getMessage() would normally provide.

Method Detail

throwLoggedException

public static void throwLoggedException(Class source,
                                        String msg,
                                        Throwable rootCause)
                                 throws UncheckedWrapperException
Throws an UncheckedWrapperException, and ensurs that it is logged at ERROR priority.

Parameters:
source - Class having the error. For Log4J reporting
msg - Error message
rootCause - The root cause exception
Throws:
UncheckedWrapperException

hasRootCause

public boolean hasRootCause()
Indicates if this exception has a root cause.


getRootCause

public Throwable getRootCause()
Gets the root cause of this exception.


toString

public String toString()
Get a string representing this exception and the root cause.


toString

public String toString(Class delegatingClass)
Get a string representing this exception and the root cause. Functions like normal toString, except that the name of the provided class will be used instead of the name of the unchecked wrapper exception. Useful when another exception class is using an unchecked wrapper exception to delegate to.


getMessage

public String getMessage()
This exception's message and the root cause's.


printStackTrace

public void printStackTrace()
Stack trace for the root cause.


printStackTrace

public void printStackTrace(PrintStream s)
Stack trace for the root cause.


printStackTrace

public void printStackTrace(PrintWriter s)
Stack trace for the root cause.



Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC