001: /*
002: * Copyright 2006 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
007: * BI Platform. The Initial Developer is Pentaho Corporation.
008: *
009: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
011: * the license for the specific language governing your rights and limitations.
012: *
013: * @created Jul 18, 2005
014: * @author Marc Batchelor
015: *
016: */
017: /**
018: *
019: * This is the base class for all Pentaho exceptions. This class handles
020: * chaining of exceptions so that it's possible to chain back to the root
021: * of an exception.
022: *
023: */package org.pentaho.util;
024:
025: import java.io.PrintStream;
026:
027: /**
028: * This is the base Pentaho Exception class that handles chained exceptions.
029: */
030: public class PentahoChainedException extends RuntimeException {
031:
032: /**
033: *
034: */
035: private static final long serialVersionUID = -2278229062123864979L;
036:
037: // private static final String CAUSEDBY = Messages.getString("PENTCHEXCEPT.ERROR_CAUSEDBY"); // Need to NLS... //$NON-NLS-1$
038:
039: public PentahoChainedException() {
040: super ();
041: }
042:
043: /**
044: * Constructor
045: *
046: * @param message
047: * The message to be carried by the exception.
048: */
049: public PentahoChainedException(String message) {
050: super (message);
051: }
052:
053: /**
054: * Constructor
055: *
056: * @param message
057: * The message.
058: * @param reas
059: * The root cause of the exception.
060: */
061: public PentahoChainedException(String message, Throwable reas) {
062: super (message, reas);
063: }
064:
065: /**
066: * Constructor
067: *
068: * @param reas
069: * The cause of this exception
070: */
071: public PentahoChainedException(Throwable reas) {
072: super (reas);
073: }
074:
075: /**
076: * Gets the root cause of the exception.
077: */
078: public Throwable getRootCause() {
079: Throwable aReason = this ;
080: Throwable lastReason = null;
081: while ((aReason != null)) {
082: lastReason = aReason;
083: aReason = aReason.getCause();
084: }
085: return (aReason != null) ? aReason : lastReason;
086: }
087:
088: /**
089: * Prints the exception trace to the specified print writer
090: */
091: public synchronized void printStackTrace(java.io.PrintWriter pw) {
092: super .printStackTrace(pw);
093: }
094:
095: /**
096: * Prints the exception trace to the specified print stream.
097: */
098: public synchronized void printStackTrace(PrintStream ps) {
099: super.printStackTrace(ps);
100: }
101:
102: }
|