net.sf.bus.util
Class NestedException

java.lang.Object
  |
  +--java.lang.Throwable
        |
        +--java.lang.Exception
              |
              +--net.sf.bus.util.NestedException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
MessageBusException, MessageBusNotFoundException

public class NestedException
extends java.lang.Exception

Base class for all nested exceptions. The exception may have a nested exception and/or a message, if desired. Also provides support for outputting the stacktrace with the nested exception

Version:
$Revision: 1.2 $
See Also:
Serialized Form

Constructor Summary
NestedException()
          Construct an empty exception
NestedException(java.lang.String message)
          Construct an exception with a message
NestedException(java.lang.String message, java.lang.Throwable nested)
          Construct an exception with a nested exception and a message
NestedException(java.lang.Throwable nested)
          Construct an exception with a nested exception
 
Method Summary
 java.lang.Throwable getNestedException()
          Returns the nested exception, or null if there isn't one
 boolean hasNestedException()
          Return true if there is a nested exception
 void printStackTrace(java.io.PrintStream ps)
          Send the stack trace to the given printstream.
 void printStackTrace(java.io.PrintWriter pw)
          Send the stack trace to the given printwriter.
 java.lang.String toString()
          Returns a combination of this exception's message (if any) and the nested exception's toString() (if any)
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, getMessage, printStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NestedException

public NestedException()
Construct an empty exception

NestedException

public NestedException(java.lang.Throwable nested)
Construct an exception with a nested exception
Parameters:
nested - the nested exception

NestedException

public NestedException(java.lang.String message)
Construct an exception with a message
Parameters:
message - the message

NestedException

public NestedException(java.lang.String message,
                       java.lang.Throwable nested)
Construct an exception with a nested exception and a message
Parameters:
message - the message
nested - the nested exception
Method Detail

printStackTrace

public void printStackTrace(java.io.PrintStream ps)
Send the stack trace to the given printstream.
Overrides:
printStackTrace in class java.lang.Throwable
Parameters:
ps - java.io.PrintStream to send the stack trace to

printStackTrace

public void printStackTrace(java.io.PrintWriter pw)
Send the stack trace to the given printwriter.
Overrides:
printStackTrace in class java.lang.Throwable
Parameters:
pw - java.io.PrintWriter to send the stack trace to

getNestedException

public java.lang.Throwable getNestedException()
Returns the nested exception, or null if there isn't one
Returns:
the nested exception

hasNestedException

public boolean hasNestedException()
Return true if there is a nested exception
Returns:
true if there is a nested exception

toString

public java.lang.String toString()
Returns a combination of this exception's message (if any) and the nested exception's toString() (if any)
Overrides:
toString in class java.lang.Throwable
Returns:
a string representation of the instance


This code may be freely distributed and modified under the terms of the GNU Lesser General Public Licence..