public class RestException extends MaybeRecoverableException
DefaultRestClient
to wrap JSON errors returned by the REST API. The HTTP status code can
be read from the exception. If the request returns a JSON error object, it will be contained in the exception. If
the object has a key "message", the value will be the message of this exception. For status codes equal to or greater
than 500 (INTERNAL SERVER ERROR) the exception will be flagged as MaybeRecoverableException.isRecoverable()
because such status codes
often describe only temporary issues and it is possible that a retry of the request will succeed.Constructor and Description |
---|
RestException(int responseCode,
AnyMap responseObject)
Create instance from response object.
|
RestException(int responseCode,
java.lang.String message)
Create an instance with a message when no response object is available.
|
Modifier and Type | Method and Description |
---|---|
int |
getResponseCode()
Get the HTTP response code of the failed request.
|
AnyMap |
getResponseObject()
Get the original JSON object of the response.
|
isRecoverable, isRecoverableCause
public RestException(int responseCode, java.lang.String message)
public RestException(int responseCode, AnyMap responseObject)
public int getResponseCode()
HttpStatus
for possible values.public AnyMap getResponseObject()