001: /*
002: * Copyright 1999,2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.catalina;
018:
019: /**
020: * General purpose exception that is thrown to indicate a lifecycle related
021: * problem. Such exceptions should generally be considered fatal to the
022: * operation of the application containing this component.
023: *
024: * @author Craig R. McClanahan
025: * @version $Revision: 1.2 $ $Date: 2004/02/27 14:58:38 $
026: */
027:
028: public final class LifecycleException extends Exception {
029:
030: //------------------------------------------------------------ Constructors
031:
032: /**
033: * Construct a new LifecycleException with no other information.
034: */
035: public LifecycleException() {
036:
037: this (null, null);
038:
039: }
040:
041: /**
042: * Construct a new LifecycleException for the specified message.
043: *
044: * @param message Message describing this exception
045: */
046: public LifecycleException(String message) {
047:
048: this (message, null);
049:
050: }
051:
052: /**
053: * Construct a new LifecycleException for the specified throwable.
054: *
055: * @param throwable Throwable that caused this exception
056: */
057: public LifecycleException(Throwable throwable) {
058:
059: this (null, throwable);
060:
061: }
062:
063: /**
064: * Construct a new LifecycleException for the specified message
065: * and throwable.
066: *
067: * @param message Message describing this exception
068: * @param throwable Throwable that caused this exception
069: */
070: public LifecycleException(String message, Throwable throwable) {
071:
072: super ();
073: this .message = message;
074: this .throwable = throwable;
075:
076: }
077:
078: //------------------------------------------------------ Instance Variables
079:
080: /**
081: * The error message passed to our constructor (if any)
082: */
083: protected String message = null;
084:
085: /**
086: * The underlying exception or error passed to our constructor (if any)
087: */
088: protected Throwable throwable = null;
089:
090: //---------------------------------------------------------- Public Methods
091:
092: /**
093: * Returns the message associated with this exception, if any.
094: */
095: public String getMessage() {
096:
097: return (message);
098:
099: }
100:
101: /**
102: * Returns the throwable that caused this exception, if any.
103: */
104: public Throwable getThrowable() {
105:
106: return (throwable);
107:
108: }
109:
110: /**
111: * Return a formatted string that describes this exception.
112: */
113: public String toString() {
114:
115: StringBuffer sb = new StringBuffer("LifecycleException: ");
116: if (message != null) {
117: sb.append(message);
118: if (throwable != null) {
119: sb.append(": ");
120: }
121: }
122: if (throwable != null) {
123: sb.append(throwable.toString());
124: }
125: return (sb.toString());
126:
127: }
128:
129: }
|