1 /* 
2  * Copyright 2005 Paul Hinds
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.tp23.antinstaller;
17
18import java.io.PrintStream;
19import java.io.PrintWriter;
20
21/**
22 *
23 * <p>Custom Installation Exception, Hopefully compatible with JDK1.3 and 1.4</p>
24 * @author Paul Hinds
25 * @version $Id: InstallException.java,v 1.1.1.1 2005/10/18 18:20:51 teknopaul Exp $
26 */
27public class InstallException extends Exception{
28
29    private Throwable cause;
30    
31    public InstallException() {
32    }
33    public InstallException(String message) {
34        super(message);
35    }
36    public InstallException(String message,Throwable cause) {
37        super(message);
38        this.cause = cause;
39    }
40    public Throwable getException() {
41        return cause;
42    }
43    public Throwable getCause() {
44        return getException();
45    }
46    public void printStackTrace() {
47        printStackTrace(System.err);
48    }
49    public void printStackTrace(PrintStream ps) {
50        synchronized (ps) {
51            super.printStackTrace(ps);
52            if (cause != null) {
53                ps.println("--- Nested Exception ---");
54                cause.printStackTrace(ps);
55            }
56        }
57    }
58    public void printStackTrace(PrintWriter pw) {
59        synchronized (pw) {
60            super.printStackTrace(pw);
61            if (cause != null) {
62                pw.println("--- Nested Exception ---");
63                cause.printStackTrace(pw);
64            }
65        }
66    }
67}
68