com.sas.net.util
Class WrapperException

java.lang.Object
  |
  +--java.lang.Throwable
        |
        +--java.lang.Exception
              |
              +--com.sas.net.util.WrapperException
Direct Known Subclasses:
WorkspacePoolException

public abstract class WrapperException
extends java.lang.Exception

Base class for exceptions that may contain nested exceptions. When there is a nested exception, toString() and printStackTrace(), etc. defer to the nested exception.

If the nested exception is itself a WrapperException, then there will be yet another layer of deferal.

This is for checked exceptions. There is also a RuntimeWrapperException to use as a base class for unchecked exceptions.

Java has it's own notion of a wrapper exception in java.lang.reflect.InvocationTargetException. This class would not exist were it not for three problems with InvocationTargetException.

This base class is often useful in the following situation where AnException extends WrapperException: public void aMethod() throws AnException { try { doStuff(); } catch (AnotherException e) { throw new AnException(e); } }

See Also:
Serialized Form

Constructor Summary
WrapperException()
          No-argument constructor.
WrapperException(java.lang.String message)
          Constructor with message.
WrapperException(java.lang.String message, java.lang.Throwable nestedException)
          Wrapper constructor.
WrapperException(java.lang.Throwable nestedException)
          Wrapper constructor.
 
Method Summary
 java.lang.Throwable fillInStackTrace()
           
 java.lang.String getLocalizedMessage()
           
 java.lang.String getMessage()
           
 java.lang.Throwable getNestedException()
          Gets the nested exception.
 void printStackTrace()
           
 void printStackTrace(java.io.PrintStream p)
           
 void printStackTrace(java.io.PrintWriter p)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WrapperException

public WrapperException()
No-argument constructor.

WrapperException

public WrapperException(java.lang.String message)
Constructor with message.
Parameters:
message - a message adding detail to the exception

WrapperException

public WrapperException(java.lang.Throwable nestedException)
Wrapper constructor.
Parameters:
nestedException - exception being wrapped

WrapperException

public WrapperException(java.lang.String message,
                        java.lang.Throwable nestedException)
Wrapper constructor.
Parameters:
message - a message to include in the exception.
nestedException - an exception being wrapped.
Method Detail

getMessage

public java.lang.String getMessage()
Overrides:
getMessage in class java.lang.Throwable
See Also:
Throwable.getMessage()

getLocalizedMessage

public java.lang.String getLocalizedMessage()
Overrides:
getLocalizedMessage in class java.lang.Throwable
See Also:
Throwable.getLocalizedMessage()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Throwable
See Also:
Throwable.toString()

printStackTrace

public void printStackTrace()
Overrides:
printStackTrace in class java.lang.Throwable
See Also:
Throwable.printStackTrace()

printStackTrace

public void printStackTrace(java.io.PrintStream p)
Overrides:
printStackTrace in class java.lang.Throwable
See Also:
Throwable.printStackTrace()

printStackTrace

public void printStackTrace(java.io.PrintWriter p)
Overrides:
printStackTrace in class java.lang.Throwable
See Also:
Throwable.printStackTrace()

fillInStackTrace

public java.lang.Throwable fillInStackTrace()
Overrides:
fillInStackTrace in class java.lang.Throwable
See Also:
Throwable.fillInStackTrace()

getNestedException

public java.lang.Throwable getNestedException()
Gets the nested exception.
Returns:
The nested exception.