KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > xtags > util > JspNestedException


1 /*
2  * Copyright 1999,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.taglibs.xtags.util;
18
19 import java.io.PrintStream JavaDoc;
20 import java.io.PrintWriter JavaDoc;
21
22 import javax.servlet.jsp.JspException JavaDoc;
23
24 /** A {@link JspException} which is nested to preserve stack traces.
25   *
26   * This class is not needed in JSP1.2 onwards.
27   *
28   * <pre>
29   * try {
30   * ...
31   * } catch (Exception e) {
32   * throw new RuntimeException(e);
33   * }
34   * </pre>
35   *
36   * @author James Strachan
37   */

38
39 public class JspNestedException extends JspException JavaDoc {
40     
41     private Throwable JavaDoc nestedException;
42
43     //-------------------------------------------------------------------------
44
public JspNestedException(Throwable JavaDoc nestedException) {
45         super( nestedException.getMessage() );
46         this.nestedException = nestedException;
47     }
48
49     public JspNestedException(String JavaDoc message,Exception JavaDoc nestedException) {
50         super( message );
51         this.nestedException = nestedException;
52     }
53
54     public void printStackTrace( PrintStream JavaDoc s ) {
55         nestedException.printStackTrace( s );
56     }
57     
58     public void printStackTrace( PrintWriter JavaDoc w ) {
59         nestedException.printStackTrace( w );
60     }
61     
62     public void printStackTrace() {
63         nestedException.printStackTrace();
64     }
65     
66     public Throwable JavaDoc fillInStackTrace() {
67         if ( nestedException == null ) {
68             return super.fillInStackTrace();
69         } else {
70             return nestedException.fillInStackTrace();
71         }
72     }
73     
74     // Properties
75
//-------------------------------------------------------------------------
76
public Throwable JavaDoc getNestedException() {
77         return nestedException;
78     }
79     
80 }
81
Popular Tags