001: /*
002: * Copyright (C) 2001, 2002 Robert MacGrogan
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: *
019: * $Archive: SourceJammer$
020: * $FileName: SourceJammerRuntimeException.java$
021: * $FileID: 4321$
022: *
023: * Last change:
024: * $AuthorName: Rob MacGrogan$
025: * $Date: 4/23/03 5:23 PM$
026: * $Comment: Replaced GPL header with LGPL header.$
027: *
028: * $KeyWordsOff: $
029: */
030:
031: package org.sourcejammer.util;
032:
033: /**
034: * Title: Source Jammer
035: * Description:
036: * Copyright: Copyright (c) 2001
037: * Company:
038: * @author Robert MacGrogan
039: * @version $Revision: 1.3 $
040: */
041:
042: import java.io.PrintStream;
043: import java.io.PrintWriter;
044:
045: /**
046: * Use this as a base class for all Source Jammer runtime exceptions.
047: */
048: public class SourceJammerRuntimeException extends RuntimeException {
049:
050: private Exception previousException = null;
051: private boolean processExceptionChain = true;
052:
053: public SourceJammerRuntimeException() {
054: super ();
055: }
056:
057: public SourceJammerRuntimeException(String msg) {
058: super (msg);
059: }
060:
061: public SourceJammerRuntimeException(String msg, Exception ex) {
062: super (msg);
063: previousException = ex;
064: }
065:
066: public Exception getPrevException() {
067: return previousException;
068: }
069:
070: public void setProcessExceptionChain(boolean value) {
071: processExceptionChain = value;
072: }
073:
074: public boolean getProcessExceptionChain() {
075: return processExceptionChain;
076: }
077:
078: public String toString() {
079: String result = super .toString();
080: if ((processExceptionChain) && (previousException != null)) {
081: result += " " + previousException.toString();
082: }
083: return result;
084: }
085:
086: public void printStackTrace() {
087: super .printStackTrace();
088: if ((processExceptionChain) && (previousException != null)) {
089: previousException.printStackTrace();
090: }
091: }
092:
093: public void printStackTrace(PrintStream s) {
094: super .printStackTrace(s);
095: if ((processExceptionChain) && (previousException != null)) {
096: previousException.printStackTrace(s);
097: }
098: }
099:
100: public void printStackTrace(PrintWriter s) {
101: super .printStackTrace(s);
102: if ((processExceptionChain) && (previousException != null)) {
103: previousException.printStackTrace(s);
104: }
105: }
106:
107: public String getMessage() {
108: String result = super .getMessage();
109: if ((processExceptionChain) && (previousException != null)) {
110: result += " " + previousException.getMessage();
111: }
112: return result;
113: }
114: }
|