org.apache.commons.httpclient
public class: HttpException [javadoc |
source]
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.io.IOException
org.apache.commons.httpclient.HttpException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
RedirectException, InvalidRedirectLocationException, InvalidCredentialsException, ProtocolException, AuthenticationException, CircularRedirectException, URIException, AuthChallengeException, CredentialsNotAvailableException, HttpRecoverableException, MalformedChallengeException, HttpContentTooLargeException, MalformedCookieException
Signals that an HTTP or HttpClient exception has occurred.
- author:
Laura - Werner
- version:
$ - Revision: 480424 $ $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
| Constructor: |
public HttpException() {
super();
this.cause = null;
}
Creates a new HttpException with a null detail message. |
public HttpException(String message) {
super(message);
this.cause = null;
}
Creates a new HttpException with the specified detail message. Parameters:
message - the exception detail message
|
public HttpException(String message,
Throwable cause) {
super(message);
this.cause = cause;
// If we're running on JDK 1.4 or later, tell Throwable what the cause was
try {
Class[] paramsClasses = new Class[] { Throwable.class };
Method initCause = Throwable.class.getMethod("initCause", paramsClasses);
initCause.invoke(this, new Object[] { cause });
} catch (Exception e) {
// The setCause method must not be available
}
}
Creates a new HttpException with the specified detail message and cause. Parameters:
message - the exception detail message
cause - the Throwable that caused this exception, or null
if the cause is unavailable, unknown, or not a Throwable
- since:
3.0 -
|
| Methods from java.lang.Throwable: |
|---|
|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
| Method from org.apache.commons.httpclient.HttpException Detail: |
public Throwable getCause() {
return cause;
}
Return the Throwable that caused this exception, or null
if the cause is unavailable, unknown, or not a Throwable. |
public String getReason() {
return reason;
} Deprecated! HttpClient - no longer uses this for itself. It is only
provided for compatibility with existing clients, and will be removed
in a future release.
Get the text description of the reason for an exception. |
public int getReasonCode() {
return this.reasonCode;
} Deprecated! HttpClient - no longer uses this for itself. It is only
provided for compatibility with existing clients, and will be removed
in a future release.
Get the status code description of the reason for an exception. |
public void printStackTrace() {
printStackTrace(System.err);
}
Print this HttpException and its stack trace to the standard error stream. |
public void printStackTrace(PrintStream s) {
try {
// JDK 1.4 has a nice printStackTrace method that prints the cause's stack
// trace too and prunes out duplicate stack frames. Call it if possible,
// which is determined by checking whether JDK 1.4's getStackTrace method is present
Class[] paramsClasses = new Class[] { };
this.getClass().getMethod("getStackTrace", paramsClasses);
super.printStackTrace(s);
} catch (Exception ex) {
// If that didn't work, print it out ourselves
// First print this exception's stack trace.
super.printStackTrace(s);
if (cause != null) {
// Print out the exception that caused this one.
// This will recurse if the cause is another HttpException.
s.print("Caused by: ");
cause.printStackTrace(s);
}
}
}
Print this HttpException and its stack trace to the specified print stream. |
public void printStackTrace(PrintWriter s) {
try {
// JDK 1.4 has a nice printStackTrace method that prints the cause's stack
// trace too and prunes out duplicate stack frames. Call it if possible,
// which is determined by checking whether JDK 1.4's getStackTrace method is present
Class[] paramsClasses = new Class[] { };
this.getClass().getMethod("getStackTrace", paramsClasses);
super.printStackTrace(s);
} catch (Exception ex) {
// If that didn't work, print it out ourselves
// First print this exception's stack trace.
super.printStackTrace(s);
if (cause != null) {
// Print out the exception that caused this one.
// This will recurse if the cause is another HttpException.
s.print("Caused by: ");
cause.printStackTrace(s);
}
}
}
Print this HttpException and its stack trace to the specified print writer. |
public void setReason(String reason) {
this.reason = reason;
} Deprecated! HttpClient - no longer uses this for itself. It is only
provided for compatibility with existing clients, and will be removed
in a future release.
Sets the text description of the reason for an exception. |
public void setReasonCode(int code) {
reasonCode = code;
} Deprecated! HttpClient - no longer uses this for itself. It is only
provided for compatibility with existing clients, and will be removed
in a future release.
Sets the status code description of the reason for an exception. |