public final class RestCallException extends IOException
Constructor and Description |
---|
RestCallException(Exception e)
Constructor.
|
RestCallException(int responseCode,
String responseMsg,
String method,
URI url,
String response)
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.
|
RestCallException(String message,
Object... args)
Constructor.
|
RestCallException(Throwable cause,
String message,
Object... args)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
org.apache.http.HttpResponse |
getHttpResponse()
Returns the HTTP response object that caused this exception.
|
protected static String |
getMessage(Throwable cause,
String msg,
String def)
Finds the message.
|
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.
|
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,
Class<?>... throwables)
Tries to reconstruct and re-throw the server-side exception.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public RestCallException(String message, Object... args)
message
- The MessageFormat
-style message.args
- Optional MessageFormat
-style arguments.public RestCallException(Throwable cause, String message, Object... args)
cause
- The cause of this exception.message
- The MessageFormat
-style message.args
- Optional MessageFormat
-style arguments.public RestCallException(Exception e)
e
- The inner cause of the exception.public RestCallException(String msg, org.apache.http.HttpResponse response) throws IOException
msg
- The exception message.response
- The HTTP response object.IOException
- Thrown by underlying stream.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 exceptionMessage
- The Throwable.getMessage()
.exceptionTrace
- The stack trace of the exception returned by Throwable.printStackTrace()
.protected void throwServerException(ClassLoader cl, Class<?>... throwables) throws Throwable
The exception is based on the following HTTP response headers:
Throwable.getMessage()
.
Throwable.printStackTrace()
.
Does nothing if the server-side exception could not be reconstructed.
Currently only supports
cl
- The classloader to use to resolve the throwable class name.throwables
- The possible throwables.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()
public String getResponseMessage()
public String getResponseStatusMessage()
protected static final String getMessage(Throwable cause, String msg, String def)
cause
- The cause.msg
- The message.def
- The default value if both above are Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.