01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package javax.servlet;
18:
19: /**
20: * Defines a general exception a servlet can throw when it
21: * encounters difficulty.
22: *
23: * @author Various
24: * @version $Version$
25: */
26: public class ServletException extends Exception {
27:
28: /**
29: * Constructs a new servlet exception.
30: */
31: public ServletException() {
32: super ();
33: }
34:
35: /**
36: * Constructs a new servlet exception with the
37: * specified message. The message can be written
38: * to the server log and/or displayed for the user.
39: *
40: * @param message a <code>String</code>
41: * specifying the text of
42: * the exception message
43: */
44: public ServletException(String message) {
45: super (message);
46: }
47:
48: /**
49: * Constructs a new servlet exception when the servlet
50: * needs to throw an exception and include a message
51: * about the "root cause" exception that interfered with its
52: * normal operation, including a description message.
53: *
54: * @param message a <code>String</code> containing
55: * the text of the exception message
56: *
57: * @param rootCause the <code>Throwable</code> exception
58: * that interfered with the servlet's
59: * normal operation, making this servlet
60: * exception necessary
61: */
62: public ServletException(String message, Throwable rootCause) {
63: super (message, rootCause);
64: }
65:
66: /**
67: * Constructs a new servlet exception when the servlet
68: * needs to throw an exception and include a message
69: * about the "root cause" exception that interfered with its
70: * normal operation. The exception's message is based on the localized
71: * message of the underlying exception.
72: *
73: * <p>This method calls the <code>getLocalizedMessage</code> method
74: * on the <code>Throwable</code> exception to get a localized exception
75: * message. When subclassing <code>ServletException</code>,
76: * this method can be overridden to create an exception message
77: * designed for a specific locale.
78: *
79: * @param rootCause the <code>Throwable</code> exception
80: * that interfered with the servlet's
81: * normal operation, making the servlet exception
82: * necessary
83: */
84: public ServletException(Throwable rootCause) {
85: super (rootCause);
86: }
87:
88: /**
89: * Returns the exception that caused this servlet exception.
90: *
91: * @return the <code>Throwable</code>
92: * that caused this servlet exception
93: */
94: public Throwable getRootCause() {
95: return getCause();
96: }
97: }
|