SMILA 1.0 API documentation

org.eclipse.smila.http.client
Class RestException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.eclipse.smila.utils.MaybeRecoverableException
              extended by org.eclipse.smila.http.client.RestException
All Implemented Interfaces:
java.io.Serializable

public class RestException
extends MaybeRecoverableException

Exception thrown by 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.

See Also:
Serialized Form

Constructor Summary
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.
 
Method Summary
 int getResponseCode()
          Get the HTTP response code of the failed request.
 AnyMap getResponseObject()
          Get the original JSON object of the response.
 
Methods inherited from class org.eclipse.smila.utils.MaybeRecoverableException
isRecoverable, isRecoverableCause
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RestException

public RestException(int responseCode,
                     java.lang.String message)
Create an instance with a message when no response object is available.


RestException

public RestException(int responseCode,
                     AnyMap responseObject)
Create instance from response object.

Method Detail

getResponseCode

public int getResponseCode()
Get the HTTP response code of the failed request. See HttpStatus for possible values.

Returns:
HTTP response status code.

getResponseObject

public AnyMap getResponseObject()
Get the original JSON object of the response. May be null.

Returns:
JSON response object if available.

SMILA 1.0 API documentation