001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package javax.management;
023:
024: /**
025: * Thrown when a java.lang.error occurs.
026: *
027: * @author <a href="mailto:juha@jboss.org">Juha Lindfors</a>
028: * @author <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>
029: * @version $Revision: 57200 $
030: *
031: * <p><b>Revisions:</b>
032: *
033: * <p><b>20020313 Juha Lindfors:</b>
034: * <ul>
035: * <li> Overriding toString() to print out the root exception </li>
036: * </ul>
037: * <p><b>20020711 Adrian Brock:</b>
038: * <ul>
039: * <li> Serialization </li>
040: * </ul>
041: */
042: public class RuntimeErrorException extends JMRuntimeException {
043: // Constants -----------------------------------------------------
044:
045: private static final long serialVersionUID = 704338937753949796L;
046:
047: // Attributes ----------------------------------------------------
048:
049: /**
050: * The wrapped error.
051: */
052: private Error error = null;
053:
054: // Constructors --------------------------------------------------
055:
056: /**
057: * Construct a new RuntimeErrorException from a given error.
058: *
059: * @param e the error to wrap.
060: */
061: public RuntimeErrorException(Error e) {
062: super ();
063: this .error = e;
064: }
065:
066: /**
067: * Construct a new RuntimeErrorException from a given error and message.
068: *
069: * @param e the error to wrap.
070: * @param message the specified message.
071: */
072: public RuntimeErrorException(Error e, String message) {
073: super (message);
074: this .error = e;
075: }
076:
077: // Public --------------------------------------------------------
078:
079: /**
080: * Retrieves the wrapped error.
081: *
082: * @return the wrapped error.
083: */
084: public java.lang.Error getTargetError() {
085: return error;
086: }
087:
088: /**
089: * Retrieves the wrapped error.
090: *
091: * @return the wrapped error.
092: */
093: public Throwable getCause() {
094: return error;
095: }
096:
097: // JMRuntimeException overrides ----------------------------------
098:
099: /**
100: * Returns a string representation of this exception. The returned string
101: * contains this exception name, message and a string representation of the
102: * target exception if it has been set.
103: *
104: * @return string representation of this exception
105: */
106: public String toString() {
107: return "RuntimeErrorException: "
108: + getMessage()
109: + ((error == null) ? "" : " Cause: " + error.toString());
110: }
111:
112: }
|