01: /*
02: * Copyright 2003-2006 Rick Knowles <winstone-devel at lists sourceforge net>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: */
07: package javax.servlet;
08:
09: import java.io.PrintWriter;
10: import java.io.PrintStream;
11:
12: /**
13: * Generic servlet exception
14: *
15: * @author Rick Knowles
16: */
17: public class ServletException extends java.lang.Exception {
18: private Throwable rootCause;
19:
20: public ServletException() {
21: super ();
22: }
23:
24: public ServletException(String message) {
25: super (message);
26: }
27:
28: public ServletException(String message, Throwable rootCause) {
29: this (message);
30: this .rootCause = rootCause;
31: }
32:
33: public ServletException(Throwable rootCause) {
34: this (rootCause != null ? rootCause.getMessage() : null);
35: this .rootCause = rootCause;
36: }
37:
38: public Throwable getRootCause() {
39: return this .rootCause;
40: }
41:
42: public void printStackTrace(PrintWriter p) {
43: if (this .rootCause != null)
44: this .rootCause.printStackTrace(p);
45: p.write("\n");
46: super .printStackTrace(p);
47: }
48:
49: public void printStackTrace(PrintStream p) {
50: if (this .rootCause != null)
51: this .rootCause.printStackTrace(p);
52: p.println("\n");
53: super .printStackTrace(p);
54: }
55:
56: public void printStackTrace() {
57: if (this.rootCause != null)
58: this.rootCause.printStackTrace();
59: super.printStackTrace();
60: }
61: }
|