org.openspml.util
Class ExceptionWrapper

java.lang.Object
  |
  +--java.lang.Throwable
        |
        +--java.lang.Exception
              |
              +--org.openspml.util.ExceptionWrapper
Direct Known Subclasses:
SpmlException

public class ExceptionWrapper
extends java.lang.Exception

An exception class that can wrap other exceptions. Used so we can consistently use SpmlException within this library, but still convey information found in other exceptions.

See Also:
SpmlException, Serialized Form

Constructor Summary
ExceptionWrapper()
          Construct an empty exception wrapper.
ExceptionWrapper(java.lang.String message)
          Construct an exception wrapper with a detail message.
ExceptionWrapper(java.lang.String message, java.lang.Throwable t)
          Create an exception wrapper from an existing exception but with a different detail message.
ExceptionWrapper(java.lang.Throwable t)
          Construct an exception wrapper with an existing exception.
 
Method Summary
 void addException(java.lang.Throwable t)
          Adds another exception to the list of wrapped exceptions.
 void clearExceptions()
          Removes all wrapped exceptions.
 java.lang.String getAllMessages()
          Return a string containing the exception class name and messages for all wrapped exceptions.
 java.lang.Throwable getException()
          Returns the first embedded exception, if any.
 java.lang.Throwable getException(int n)
          Returns the Nth embedded exception, if any.
 int getExceptionCount()
          Returns the number of wrapped Exceptions.
 java.util.List getExceptions()
          Return the list of nested exceptions.
 java.lang.String getMessage()
          Return a detail message for this exception.
 void printStackTrace()
          Throwable overload to cause printing of the nested exception stack traces as well as our own.
 void printStackTrace(java.io.PrintStream str)
          Throwable overload to cause printing of the nested exception stack traces as well as our own.
 void printStackTrace(java.io.PrintWriter out)
          Throwable overload to cause printing of the nested exception stack traces as well as our own.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExceptionWrapper

public ExceptionWrapper()
Construct an empty exception wrapper.

ExceptionWrapper

public ExceptionWrapper(java.lang.String message)
Construct an exception wrapper with a detail message.
Parameters:
message - detail message

ExceptionWrapper

public ExceptionWrapper(java.lang.Throwable t)
Construct an exception wrapper with an existing exception.

The detail message for the throwable will become the default message for this wrapper.

Parameters:
t - nested throwable

ExceptionWrapper

public ExceptionWrapper(java.lang.String message,
                        java.lang.Throwable t)
Create an exception wrapper from an existing exception but with a different detail message.
Parameters:
message - detail message
t - nested throwable
Method Detail

addException

public void addException(java.lang.Throwable t)
Adds another exception to the list of wrapped exceptions.

clearExceptions

public void clearExceptions()
Removes all wrapped exceptions.

getExceptions

public java.util.List getExceptions()
Return the list of nested exceptions.

getExceptionCount

public int getExceptionCount()
Returns the number of wrapped Exceptions.

getException

public java.lang.Throwable getException()
Returns the first embedded exception, if any.

getException

public java.lang.Throwable getException(int n)
Returns the Nth embedded exception, if any.

getMessage

public java.lang.String getMessage()
Return a detail message for this exception.

If there is a embedded exception, and if this exception has no detail message of its own, getMessage method will return the detail message from the first embedded exception.

Overrides:
getMessage in class java.lang.Throwable

getAllMessages

public java.lang.String getAllMessages()
Return a string containing the exception class name and messages for all wrapped exceptions.

printStackTrace

public void printStackTrace()
Throwable overload to cause printing of the nested exception stack traces as well as our own.
Overrides:
printStackTrace in class java.lang.Throwable

printStackTrace

public void printStackTrace(java.io.PrintStream str)
Throwable overload to cause printing of the nested exception stack traces as well as our own.
Overrides:
printStackTrace in class java.lang.Throwable

printStackTrace

public void printStackTrace(java.io.PrintWriter out)
Throwable overload to cause printing of the nested exception stack traces as well as our own.
Overrides:
printStackTrace in class java.lang.Throwable