KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > module > sitemesh > factory > FactoryException


1 /*
2  * Title: FactoryException
3  * Description:
4  *
5  * This software is published under the terms of the OpenSymphony Software
6  * License version 1.1, of which a copy has been included with this
7  * distribution in the LICENSE.txt file.
8  */

9
10 package com.opensymphony.module.sitemesh.factory;
11
12 import java.io.PrintStream JavaDoc;
13 import java.io.PrintWriter JavaDoc;
14
15 /**
16  * This RuntimeException is thrown by the Factory if it cannot initialize or perform
17  * an appropriate function.
18  *
19  * @author <a HREF="mailto:joe@truemesh.com">Joe Walnes</a>
20  * @version $Revision: 1.1 $
21  */

22 public class FactoryException extends RuntimeException JavaDoc {
23     protected Exception JavaDoc exception = null;
24
25     public FactoryException() {
26         super();
27     }
28
29     public FactoryException(String JavaDoc msg) {
30         super(msg);
31     }
32
33     public FactoryException(Exception JavaDoc e) {
34         super();
35         exception = e;
36     }
37
38     public FactoryException(String JavaDoc msg, Exception JavaDoc e) {
39         super(msg + ": " + e);
40         exception = e;
41     }
42
43     /**
44      * Get the original cause of the Exception. Returns null if not known.
45      */

46     public Exception JavaDoc getRootCause() {
47         return exception;
48     }
49
50     public void printStackTrace() {
51         super.printStackTrace();
52         if (exception != null) {
53             synchronized (System.err) {
54                 System.err.println("\nRoot cause:");
55                 exception.printStackTrace();
56             }
57         }
58     }
59
60     public void printStackTrace(PrintStream JavaDoc s) {
61         super.printStackTrace(s);
62         if (exception != null) {
63             synchronized (s) {
64                 s.println("\nRoot cause:");
65                 exception.printStackTrace(s);
66             }
67         }
68     }
69
70     public void printStackTrace(PrintWriter JavaDoc s) {
71         super.printStackTrace(s);
72         if (exception != null) {
73             synchronized (s) {
74                 s.println("\nRoot cause:");
75                 exception.printStackTrace(s);
76             }
77         }
78     }
79 }
Popular Tags