KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > util > PentahoChainedException


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11  * the license for the specific language governing your rights and limitations.
12  *
13  * @created Jul 18, 2005
14  * @author Marc Batchelor
15  *
16  */

17 /**
18  *
19  * This is the base class for all Pentaho exceptions. This class handles
20  * chaining of exceptions so that it's possible to chain back to the root
21  * of an exception.
22  *
23  */

24 package org.pentaho.util;
25
26 import java.io.PrintStream JavaDoc;
27
28 /**
29  * This is the base Pentaho Exception class that handles chained exceptions.
30  */

31 public class PentahoChainedException extends RuntimeException JavaDoc {
32
33     /**
34      *
35      */

36     private static final long serialVersionUID = -2278229062123864979L;
37
38     // private static final String CAUSEDBY = Messages.getString("PENTCHEXCEPT.ERROR_CAUSEDBY"); // Need to NLS... //$NON-NLS-1$
39

40     public PentahoChainedException() {
41         super();
42     }
43
44     /**
45      * Constructor
46      *
47      * @param message
48      * The message to be carried by the exception.
49      */

50     public PentahoChainedException(String JavaDoc message) {
51         super(message);
52     }
53
54     /**
55      * Constructor
56      *
57      * @param message
58      * The message.
59      * @param reas
60      * The root cause of the exception.
61      */

62     public PentahoChainedException(String JavaDoc message, Throwable JavaDoc reas) {
63         super(message, reas);
64     }
65
66     /**
67      * Constructor
68      *
69      * @param reas
70      * The cause of this exception
71      */

72     public PentahoChainedException(Throwable JavaDoc reas) {
73         super(reas);
74     }
75
76
77     /**
78      * Gets the root cause of the exception.
79      */

80     public Throwable JavaDoc getRootCause() {
81         Throwable JavaDoc aReason = this;
82         Throwable JavaDoc lastReason = null;
83         while ((aReason != null) ) {
84             lastReason = aReason;
85             aReason = aReason.getCause();
86         }
87         return (aReason != null) ? aReason : lastReason;
88     }
89
90     /**
91      * Prints the exception trace to the specified print writer
92      */

93     public synchronized void printStackTrace(java.io.PrintWriter JavaDoc pw) {
94         super.printStackTrace(pw);
95     }
96
97     /**
98      * Prints the exception trace to the specified print stream.
99      */

100     public synchronized void printStackTrace(PrintStream JavaDoc ps) {
101         super.printStackTrace(ps);
102     }
103
104 }
105
Popular Tags