public final class RestCallException extends IOException
400+
HTTP response code against a remote resource.Constructor and Description |
---|
RestCallException(Exception e)
Constructor.
|
RestCallException(int responseCode,
String responseMsg,
String method,
URI url,
String response)
Constructor.
|
RestCallException(String msg)
Constructor.
|
RestCallException(String msg,
org.apache.http.HttpResponse response)
Create an exception with a simple message and the status code and body of the specified response.
|
Modifier and Type | Method and Description |
---|---|
org.apache.http.HttpResponse |
getHttpResponse()
Returns the HTTP response object that caused this exception.
|
int |
getResponseCode()
Returns the HTTP response status code.
|
String |
getResponseMessage()
Returns the HTTP response message body text.
|
String |
getResponseStatusMessage()
Returns the response status message as a plain string.
|
RestCallException |
initCause(Throwable cause)
Sets the inner cause for this exception.
|
protected RestCallException |
setHttpResponse(org.apache.http.HttpResponse httpResponse)
Sets the HTTP response object that caused this exception.
|
protected RestCallException |
setServerException(org.apache.http.Header exceptionName,
org.apache.http.Header exceptionMessage,
org.apache.http.Header exceptionTrace)
Sets the server-side exception details.
|
protected void |
throwServerException(ClassLoader cl)
Tries to reconstruct and re-throw the server-side exception.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public RestCallException(String msg)
msg
- The exception message.public RestCallException(Exception e)
e
- The inner cause of the exception.public RestCallException(String msg, org.apache.http.HttpResponse response) throws org.apache.http.ParseException, IOException
msg
- The exception message.response
- The HTTP response object.org.apache.http.ParseException
IOException
public RestCallException(int responseCode, String responseMsg, String method, URI url, String response)
responseCode
- The response code.responseMsg
- The response message.method
- The HTTP method (for message purposes).url
- The HTTP URL (for message purposes).response
- The response from the server.protected RestCallException setServerException(org.apache.http.Header exceptionName, org.apache.http.Header exceptionMessage, org.apache.http.Header exceptionTrace)
exceptionName
- The Exception-Name:
header specifying the full name of the exception.exceptionMessage
- The Exception-Message:
header specifying the message returned by Throwable.getMessage()
.exceptionTrace
- The stack trace of the exception returned by Throwable.printStackTrace()
.protected void throwServerException(ClassLoader cl) throws Throwable
The exception is based on the following HTTP response headers:
Exception-Name:
- The full class name of the exception.
Exception-Message:
- The message returned by Throwable.getMessage()
.
Exception-Trace:
- The stack trace of the exception returned by Throwable.printStackTrace()
.
Does nothing if the server-side exception could not be reconstructed.
Currently only supports Throwables
with either a public no-arg constructor
or a public constructor that takes in a simple string message.
cl
- The classloader to use to resolve the throwable class name.Throwable
- If the throwable could be reconstructed.protected RestCallException setHttpResponse(org.apache.http.HttpResponse httpResponse)
httpResponse
- The HTTP response object.public org.apache.http.HttpResponse getHttpResponse()
public int getResponseCode()
0
.public String getResponseMessage()
public String getResponseStatusMessage()
public RestCallException initCause(Throwable cause)
Copyright © 2018 Apache. All rights reserved.