001: /*
002: *
003: * The DbUnit Database Testing Framework
004: * Copyright (C)2002-2004, DbUnit.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: */
021:
022: package org.dbunit;
023:
024: import org.slf4j.Logger;
025: import org.slf4j.LoggerFactory;
026:
027: import java.io.PrintStream;
028: import java.io.PrintWriter;
029:
030: /**
031: * @author Manuel Laflamme
032: * @version $Revision: 554 $
033: */
034: public class DatabaseUnitRuntimeException extends RuntimeException {
035:
036: /**
037: * Logger for this class
038: */
039: private static final Logger logger = LoggerFactory
040: .getLogger(DatabaseUnitRuntimeException.class);
041:
042: private final Throwable _e;
043:
044: /**
045: * Constructs an <code>DatabaseUnitRuntimeException</code> with no specified
046: * detail message and no encapsulated exception.
047: */
048: public DatabaseUnitRuntimeException() {
049: super ();
050: _e = null;
051: }
052:
053: /**
054: * Constructs an <code>DatabaseUnitRuntimeException</code> with the specified
055: * detail message and no encapsulated exception.
056: */
057: public DatabaseUnitRuntimeException(String msg) {
058: super (msg);
059: _e = null;
060: }
061:
062: /**
063: * Constructs an <code>DatabaseUnitRuntimeException</code> with the specified
064: * detail message and encapsulated exception.
065: */
066: public DatabaseUnitRuntimeException(String msg, Throwable e) {
067: super (msg);
068: _e = e;
069: }
070:
071: /**
072: * Constructs an <code>DatabaseUnitRuntimeException</code> with the encapsulated
073: * exception and use its message as detail message.
074: */
075: public DatabaseUnitRuntimeException(Throwable e) {
076: super (e.toString());
077: _e = e;
078: }
079:
080: /**
081: * Returns the encapsuled exception or <code>null</code> if none.
082: */
083: public Throwable getException() {
084: logger.debug("getException() - start");
085:
086: return _e;
087: }
088:
089: //////////////////////////////////////////////////////////////////////
090: // Exception class
091:
092: /**
093: *
094: */
095: public void printStackTrace() {
096: logger.debug("printStackTrace() - start");
097:
098: super .printStackTrace();
099: if (_e != null)
100: _e.printStackTrace();
101: }
102:
103: /**
104: *
105: */
106: public void printStackTrace(PrintStream s) {
107: logger.debug("printStackTrace(s=" + s + ") - start");
108:
109: super .printStackTrace(s);
110: if (_e != null)
111: _e.printStackTrace(s);
112: }
113:
114: /**
115: *
116: */
117: public void printStackTrace(PrintWriter s) {
118: logger.debug("printStackTrace(s=" + s + ") - start");
119:
120: super.printStackTrace(s);
121: if (_e != null)
122: _e.printStackTrace(s);
123: }
124: }
|