01: /*
02: * Copyright 2002 Sun Microsystems, Inc. All
03: * rights reserved. Use of this product is subject
04: * to license terms. Federal Acquisitions:
05: * Commercial Software -- Government Users
06: * Subject to Standard License Terms and
07: * Conditions.
08: *
09: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
10: * are trademarks or registered trademarks of Sun Microsystems,
11: * Inc. in the United States and other countries.
12: */
13:
14: package com.sun.portal.container;
15:
16: import java.lang.Exception;
17:
18: import java.io.PrintWriter;
19: import java.io.BufferedReader;
20: import java.io.PrintStream;
21: import java.io.PrintWriter;
22:
23: /**
24: * A ContainerException is thrown when there is an unrecoverable error
25: * occurs when container code get executed.
26: **/
27: public class ContainerException extends Exception {
28:
29: protected Throwable wrapped = null;
30:
31: /**
32: * Constructs a new exception with the specified message, indicating an
33: * error in the provider as happened.<br><br>
34: *
35: * @param msg The descriptive message.
36: */
37: public ContainerException(String msg) {
38: super (msg);
39: }
40:
41: /**
42: * Constructs a new exception with the specified message, and the original
43: * <code>exception</code> or <code>error</code>, indicating an error in the
44: * container as happened.<br><br>
45: *
46: * @param msg The descriptive message.
47: * @param e The original <code>exception</code> or <code>error</code>.
48: */
49: public ContainerException(String msg, Throwable e) {
50: super (msg);
51: wrapped = e;
52: }
53:
54: public Throwable getWrapped() {
55: return wrapped;
56: }
57:
58: public String toString() {
59: StringBuffer b = new StringBuffer();
60:
61: b.append(super .toString());
62: if (getWrapped() != null) {
63: b.append(wrapped.toString());
64: }
65:
66: return b.toString();
67: }
68:
69: public void printStackTrace() {
70: super .printStackTrace();
71: if (getWrapped() != null) {
72: wrapped.printStackTrace();
73: }
74: }
75:
76: public void printStackTrace(PrintStream s) {
77: super .printStackTrace(s);
78: if (getWrapped() != null) {
79: wrapped.printStackTrace(s);
80: }
81: }
82:
83: public void printStackTrace(PrintWriter s) {
84: super.printStackTrace(s);
85: if (getWrapped() != null) {
86: wrapped.printStackTrace(s);
87: }
88: }
89: }
|