com.arsdigita.util
Class WrappedError

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Error
          extended bycom.arsdigita.util.WrappedError
All Implemented Interfaces:
Serializable

public class WrappedError
extends Error

A wrapper error that can be used to rethrow another throwable. 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.

Since:
2004-01-19
Version:
$Id: //core-platform/dev/src/com/arsdigita/util/WrappedError.java#3 $
See Also:
Serialized Form

Field Summary
static String versionId
           
 
Constructor Summary
WrappedError(String msg)
          Constructor which only takes a msg, which will cause this WrappedError to behave like a normal RuntimeException.
WrappedError(String s, Throwable rootCause)
          Constructor which takes a message string and a root cause that this exception will be wrapping.
WrappedError(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 WrappedError, 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

WrappedError

public WrappedError(String msg)
Constructor which only takes a msg, which will cause this WrappedError 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.


WrappedError

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


WrappedError

public WrappedError(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 WrappedError
Throws an WrappedError, 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:
WrappedError

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 21 2004:2337 UTC