KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > winstone > WinstoneException


1 /*
2  * Copyright 2003-2006 Rick Knowles <winstone-devel at lists sourceforge net>
3  * Distributed under the terms of either:
4  * - the common development and distribution license (CDDL), v1.0; or
5  * - the GNU Lesser General Public License, v2.1 or later
6  */

7 package winstone;
8
9 import java.io.PrintStream JavaDoc;
10 import java.io.PrintWriter JavaDoc;
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 JavaDoc {
22     private Throwable JavaDoc 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 JavaDoc 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 JavaDoc pMsg, Throwable JavaDoc 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 JavaDoc 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 JavaDoc pError) {
65         this.nestedError = pError;
66     }
67
68     public void printStackTrace(PrintWriter JavaDoc 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 JavaDoc 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 }
88
Popular Tags