KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > LifecycleException


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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
18
19 package org.apache.catalina;
20
21
22 /**
23  * General purpose exception that is thrown to indicate a lifecycle related
24  * problem. Such exceptions should generally be considered fatal to the
25  * operation of the application containing this component.
26  *
27  * @author Craig R. McClanahan
28  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
29  */

30
31 public final class LifecycleException extends Exception JavaDoc {
32
33
34     //------------------------------------------------------------ Constructors
35

36
37     /**
38      * Construct a new LifecycleException with no other information.
39      */

40     public LifecycleException() {
41
42         this(null, null);
43
44     }
45
46
47     /**
48      * Construct a new LifecycleException for the specified message.
49      *
50      * @param message Message describing this exception
51      */

52     public LifecycleException(String JavaDoc message) {
53
54         this(message, null);
55
56     }
57
58
59     /**
60      * Construct a new LifecycleException for the specified throwable.
61      *
62      * @param throwable Throwable that caused this exception
63      */

64     public LifecycleException(Throwable JavaDoc throwable) {
65
66         this(null, throwable);
67
68     }
69
70
71     /**
72      * Construct a new LifecycleException for the specified message
73      * and throwable.
74      *
75      * @param message Message describing this exception
76      * @param throwable Throwable that caused this exception
77      */

78     public LifecycleException(String JavaDoc message, Throwable JavaDoc throwable) {
79
80         super();
81         this.message = message;
82         this.throwable = throwable;
83
84     }
85
86
87     //------------------------------------------------------ Instance Variables
88

89
90     /**
91      * The error message passed to our constructor (if any)
92      */

93     protected String JavaDoc message = null;
94
95
96     /**
97      * The underlying exception or error passed to our constructor (if any)
98      */

99     protected Throwable JavaDoc throwable = null;
100
101
102     //---------------------------------------------------------- Public Methods
103

104
105     /**
106      * Returns the message associated with this exception, if any.
107      */

108     public String JavaDoc getMessage() {
109
110         return (message);
111
112     }
113
114
115     /**
116      * Returns the throwable that caused this exception, if any.
117      */

118     public Throwable JavaDoc getThrowable() {
119
120         return (throwable);
121
122     }
123
124
125     /**
126      * Return a formatted string that describes this exception.
127      */

128     public String JavaDoc toString() {
129
130         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("LifecycleException: ");
131         if (message != null) {
132             sb.append(message);
133             if (throwable != null) {
134                 sb.append(": ");
135             }
136         }
137         if (throwable != null) {
138             sb.append(throwable.toString());
139         }
140         return (sb.toString());
141
142     }
143
144
145 }
146
Popular Tags