/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package javax.management;
/**
* Wraps runtime exceptions thrown when performing operations on MBeans.
*
* @author Adrian Brock
* @version $Revision: 1.3.6.1 $
*
*
Revisions:
*
*
20020313 Juha Lindfors:
*
* - Overriding toString() to print out the root exception
*
* 20020711 Adrian Brock:
*
*/
public class RuntimeOperationsException
extends JMRuntimeException
{
// Constants -----------------------------------------------------
private static final long serialVersionUID = -8408923047489133588L;
// Attributes ----------------------------------------------------
/**
* The wrapped runtime exception.
*/
private RuntimeException runtimeException = null;
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
/**
* Construct a new RuntimeOperationsException from a given runtime exception.
*
* @param e the runtime exception to wrap.
*/
public RuntimeOperationsException(RuntimeException e)
{
super();
this.runtimeException = e;
}
/**
* Construct a new RuntimeOperationsException from a given runtime exception
* and message.
*
* @param e the runtime exception to wrap.
* @param message the specified message.
*/
public RuntimeOperationsException(RuntimeException e, String message)
{
super(message);
this.runtimeException = e;
}
// Public --------------------------------------------------------
/**
* Retrieves the wrapped runtime exception.
*
* @return the wrapped runtime exception.
*/
public RuntimeException getTargetException()
{
return runtimeException;
}
// JMRuntimeException overrides ----------------------------------
/**
* Returns a string representation of this exception. The returned string
* contains this exception name, message and a string representation of the
* target exception if it has been set.
*
* @return string representation of this exception
*/
public String toString()
{
return "RuntimeOperationsException: " + getMessage() + ((runtimeException == null) ? "" : "\nCause: " + runtimeException.toString());
}
// Private -------------------------------------------------------
}