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.connector;
018:
019: import java.io.IOException;
020:
021: /**
022: * Wrap an IOException identifying it as being caused by an abort
023: * of a request by a remote client.
024: *
025: * @author Glenn L. Nielsen
026: * @version $Revision: 1.2 $ $Date: 2004/02/27 14:58:41 $
027: */
028:
029: public final class ClientAbortException extends IOException {
030:
031: //------------------------------------------------------------ Constructors
032:
033: /**
034: * Construct a new ClientAbortException with no other information.
035: */
036: public ClientAbortException() {
037:
038: this (null, null);
039:
040: }
041:
042: /**
043: * Construct a new ClientAbortException for the specified message.
044: *
045: * @param message Message describing this exception
046: */
047: public ClientAbortException(String message) {
048:
049: this (message, null);
050:
051: }
052:
053: /**
054: * Construct a new ClientAbortException for the specified throwable.
055: *
056: * @param throwable Throwable that caused this exception
057: */
058: public ClientAbortException(Throwable throwable) {
059:
060: this (null, throwable);
061:
062: }
063:
064: /**
065: * Construct a new ClientAbortException for the specified message
066: * and throwable.
067: *
068: * @param message Message describing this exception
069: * @param throwable Throwable that caused this exception
070: */
071: public ClientAbortException(String message, Throwable throwable) {
072:
073: super ();
074: this .message = message;
075: this .throwable = throwable;
076:
077: }
078:
079: //------------------------------------------------------ Instance Variables
080:
081: /**
082: * The error message passed to our constructor (if any)
083: */
084: protected String message = null;
085:
086: /**
087: * The underlying exception or error passed to our constructor (if any)
088: */
089: protected Throwable throwable = null;
090:
091: //---------------------------------------------------------- Public Methods
092:
093: /**
094: * Returns the message associated with this exception, if any.
095: */
096: public String getMessage() {
097:
098: return (message);
099:
100: }
101:
102: /**
103: * Returns the throwable that caused this exception, if any.
104: */
105: public Throwable getThrowable() {
106:
107: return (throwable);
108:
109: }
110:
111: /**
112: * Return a formatted string that describes this exception.
113: */
114: public String toString() {
115:
116: StringBuffer sb = new StringBuffer("ClientAbortException: ");
117: if (message != null) {
118: sb.append(message);
119: if (throwable != null) {
120: sb.append(": ");
121: }
122: }
123: if (throwable != null) {
124: sb.append(throwable.toString());
125: }
126: return (sb.toString());
127:
128: }
129:
130: }
|