01: /*
02: * Title: FactoryException
03: * Description:
04: *
05: * This software is published under the terms of the OpenSymphony Software
06: * License version 1.1, of which a copy has been included with this
07: * distribution in the LICENSE.txt file.
08: */
09:
10: package com.opensymphony.module.sitemesh.factory;
11:
12: import java.io.PrintStream;
13: import java.io.PrintWriter;
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 {
23: protected Exception exception = null;
24:
25: public FactoryException() {
26: super ();
27: }
28:
29: public FactoryException(String msg) {
30: super (msg);
31: }
32:
33: public FactoryException(Exception e) {
34: super ();
35: exception = e;
36: }
37:
38: public FactoryException(String msg, Exception 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 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 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 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: }
|