org.spiffyui.client.rest
Class RESTException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.spiffyui.client.rest.RESTException
All Implemented Interfaces:
java.io.Serializable

public class RESTException
extends java.lang.Exception

This exception represents a successful return from a REST call with an error payload. This exception parses the payload and returns all the parts of the exception.

This exception follows the SOAP fault format. The basic structure looks like this:

 {
     "Fault": {
         "Code": {
             "Value": "Sender",
             "Subcode": {
                 "Value": "MessageTimeout" 
             } 
         },
         "Reason": {
             "Text": "Sender Timeout" 
         },
         "Detail": {
             "MaxTime": "P5M" 
         } 
     }
 }
 

The fields in this class map to this JSON structure.

See Also:
Serialized Form

Field Summary
static java.lang.String AUTH_SERVER_UNAVAILABLE
          This constant indicates that the core server was not able to contact the authentication server.
static java.lang.String INVALID_AUTH_HEADER
          This constant indicates that the server returned a 401, but the required HTTP header was invalid
static java.lang.String INVALID_RESPONSE
          This is a constant error code to indicate the JSON returned from the server was parsable, but still invalid.
static java.lang.String NO_AUTH_HEADER
          This constant indicates that the server returned a 401, but did not return the required authentication HTTP header
static java.lang.String NO_SERVER_RESPONSE
          This constant indicates that we were unable to contact the server.
static java.lang.String UNPARSABLE_RESPONSE
          This is a constant error code to indicate the response was not well formed JSON
static java.lang.String XSS_ERROR
          This constant indicates that the server returned a 401, but did not return the required authentication HTTP header
 
Constructor Summary
RESTException(java.lang.String code, java.lang.String subcode, java.lang.String reason, java.util.Map<java.lang.String,java.lang.String> details, int responseCode, java.lang.String url)
          Creates a new RESTException
 
Method Summary
static RESTException generateInvalidJSONException(java.lang.String url)
          Gets a generic exception representing invalid JSON
 java.lang.String getCode()
          The code for the exception
 java.util.Map<java.lang.String,java.lang.String> getDetails()
          The details for this exception
 java.lang.String getReason()
          The reason for this exception
 int getResponseCode()
          Gets the server response code that came with this error message
 java.lang.String getSubcode()
          The subcode for this exception
 java.lang.String getUrl()
          Gets the URL that was called when this RESTException was thrown
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNPARSABLE_RESPONSE

public static final java.lang.String UNPARSABLE_RESPONSE
This is a constant error code to indicate the response was not well formed JSON

See Also:
Constant Field Values

INVALID_RESPONSE

public static final java.lang.String INVALID_RESPONSE
This is a constant error code to indicate the JSON returned from the server was parsable, but still invalid.

See Also:
Constant Field Values

NO_SERVER_RESPONSE

public static final java.lang.String NO_SERVER_RESPONSE
This constant indicates that we were unable to contact the server. That might be because we are offline or the server connection timed out.

See Also:
Constant Field Values

NO_AUTH_HEADER

public static final java.lang.String NO_AUTH_HEADER
This constant indicates that the server returned a 401, but did not return the required authentication HTTP header

See Also:
Constant Field Values

INVALID_AUTH_HEADER

public static final java.lang.String INVALID_AUTH_HEADER
This constant indicates that the server returned a 401, but the required HTTP header was invalid

See Also:
Constant Field Values

XSS_ERROR

public static final java.lang.String XSS_ERROR
This constant indicates that the server returned a 401, but did not return the required authentication HTTP header

See Also:
Constant Field Values

AUTH_SERVER_UNAVAILABLE

public static final java.lang.String AUTH_SERVER_UNAVAILABLE
This constant indicates that the core server was not able to contact the authentication server.

See Also:
Constant Field Values
Constructor Detail

RESTException

public RESTException(java.lang.String code,
                     java.lang.String subcode,
                     java.lang.String reason,
                     java.util.Map<java.lang.String,java.lang.String> details,
                     int responseCode,
                     java.lang.String url)
Creates a new RESTException

Parameters:
code - the exception code
subcode - the optional exception subcode
reason - the optional exception reason
details - the optional exception details
responseCode - the HTTP response code
url - the URL for this exception
Method Detail

getCode

public java.lang.String getCode()
The code for the exception

Returns:
gets the return code for this exception - required

getSubcode

public java.lang.String getSubcode()
The subcode for this exception

Returns:
the subcode - optional

getReason

public java.lang.String getReason()
The reason for this exception

Returns:
the exception reason - required

getDetails

public java.util.Map<java.lang.String,java.lang.String> getDetails()
The details for this exception

Returns:
a map of the details for this exception

getResponseCode

public int getResponseCode()
Gets the server response code that came with this error message

Returns:
the HTTP response code

getUrl

public java.lang.String getUrl()
Gets the URL that was called when this RESTException was thrown

Returns:
the URL

generateInvalidJSONException

public static RESTException generateInvalidJSONException(java.lang.String url)
Gets a generic exception representing invalid JSON

Parameters:
url - the URL where this bad JSON came from
Returns:
the exception

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Throwable