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 winstone;
08:
09: import java.io.PrintStream;
10: import java.io.PrintWriter;
11:
12: /**
13: * Master exception within the servlet container. This is thrown whenever a
14: * non-recoverable error occurs that we want to throw to the top of the
15: * application.
16: *
17: * @author <a href="mailto:rick_knowles@hotmail.com">Rick Knowles</a>
18: * @version $Id: WinstoneException.java,v 1.1 2004/03/08 15:27:21 rickknowles
19: * Exp $
20: */
21: public class WinstoneException extends RuntimeException {
22: private Throwable nestedError = null;
23:
24: /**
25: * Create an exception with a useful message for the system administrator.
26: *
27: * @param pMsg
28: * Error message for to be used for administrative
29: * troubleshooting
30: */
31: public WinstoneException(String pMsg) {
32: super (pMsg);
33: }
34:
35: /**
36: * Create an exception with a useful message for the system administrator
37: * and a nested throwable object.
38: *
39: * @param pMsg
40: * Error message for administrative troubleshooting
41: * @param pError
42: * The actual exception that occurred
43: */
44: public WinstoneException(String pMsg, Throwable pError) {
45: super (pMsg);
46: this .setNestedError(pError);
47: }
48:
49: /**
50: * Get the nested error or exception
51: *
52: * @return The nested error or exception
53: */
54: public Throwable getNestedError() {
55: return this .nestedError;
56: }
57:
58: /**
59: * Set the nested error or exception
60: *
61: * @param pError
62: * The nested error or exception
63: */
64: private void setNestedError(Throwable pError) {
65: this .nestedError = pError;
66: }
67:
68: public void printStackTrace(PrintWriter p) {
69: if (this .nestedError != null)
70: this .nestedError.printStackTrace(p);
71: p.write("\n");
72: super .printStackTrace(p);
73: }
74:
75: public void printStackTrace(PrintStream p) {
76: if (this .nestedError != null)
77: this .nestedError.printStackTrace(p);
78: p.println("\n");
79: super .printStackTrace(p);
80: }
81:
82: public void printStackTrace() {
83: if (this.nestedError != null)
84: this.nestedError.printStackTrace();
85: super.printStackTrace();
86: }
87: }
|