org.jets3t.service
Class ServiceException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.jets3t.service.ServiceException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
S3ServiceException

public class ServiceException
extends java.lang.Exception

Exception for use by StorageService and related utilities. This exception can hold useful additional information about errors that occur when communicating with a service.

See Also:
Serialized Form

Constructor Summary
ServiceException()
          Create a service exception without any useful information.
ServiceException(java.lang.String message)
          Create a service exception that includes a specific message.
ServiceException(java.lang.String message, java.lang.String xmlMessage)
          Create a service exception that includes the XML error document returned by service.
ServiceException(java.lang.String message, java.lang.String xmlMessage, java.lang.Throwable cause)
          Create a service exception that includes a specific message, an optional XML error document returned by service, and an optional underlying cause exception.
ServiceException(java.lang.String message, java.lang.Throwable cause)
          Create a service exception that includes a specific message and an optional underlying cause exception.
ServiceException(java.lang.Throwable cause)
          Create a service exception that includes an underlying cause exception.
 
Method Summary
 java.lang.String getErrorCode()
           
 java.lang.String getErrorHostId()
           
 java.lang.String getErrorMessage()
           
 java.lang.String getErrorRequestId()
           
 java.lang.String getRequestHost()
           
 java.lang.String getRequestPath()
           
 java.lang.String getRequestVerb()
           
 int getResponseCode()
           
 java.lang.String getResponseDate()
           
 java.util.Map<java.lang.String,java.lang.String> getResponseHeaders()
           
 java.lang.String getResponseStatus()
           
 java.lang.String getXmlMessage()
           
 com.jamesmurty.utils.XMLBuilder getXmlMessageAsBuilder()
           
 boolean isParsedFromXmlMessage()
           
 void setErrorCode(java.lang.String code)
          Set the exception's error code; for internal use only.
 void setErrorHostId(java.lang.String hostId)
          Set the exception's host ID; for internal use only.
 void setErrorMessage(java.lang.String message)
          Set the exception's error message; for internal use only.
 void setErrorRequestId(java.lang.String requestId)
          Set the exception's request ID; for internal use only.
 void setRequestAndHostIds(java.lang.String errorRequestId, java.lang.String errorHostId)
          Allow the Request and Host Id fields to be populated in situations where this information is not available from an XML response error document.
 void setRequestHost(java.lang.String requestHost)
          Set the exception's HTTP request hostname; for internal use only.
 void setRequestPath(java.lang.String requestPath)
          Set the exception's HTTP request path; for internal use only.
 void setRequestVerb(java.lang.String requestVerb)
          Set the exception's HTTP request verb; for internal use only.
 void setResponseCode(int responseCode)
          Set the exception's HTTP response code; for internal use only.
 void setResponseDate(java.lang.String responseDate)
          Set the exception's HTTP response date; for internal use only.
 void setResponseHeaders(java.util.Map<java.lang.String,java.lang.String> responseHeaders)
          Set the exception's HTTP response headers; for internal use only.
 void setResponseStatus(java.lang.String responseStatus)
          Set the exception's HTTP response status; for internal use only.
 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
 

Constructor Detail

ServiceException

public ServiceException(java.lang.String message,
                        java.lang.String xmlMessage)
Create a service exception that includes the XML error document returned by service.

Parameters:
message -
xmlMessage -

ServiceException

public ServiceException(java.lang.String message,
                        java.lang.String xmlMessage,
                        java.lang.Throwable cause)
Create a service exception that includes a specific message, an optional XML error document returned by service, and an optional underlying cause exception.

Parameters:
message -
xmlMessage -
cause -

ServiceException

public ServiceException()
Create a service exception without any useful information.


ServiceException

public ServiceException(java.lang.String message,
                        java.lang.Throwable cause)
Create a service exception that includes a specific message and an optional underlying cause exception.

Parameters:
message -
cause -

ServiceException

public ServiceException(java.lang.String message)
Create a service exception that includes a specific message.

Parameters:
message -

ServiceException

public ServiceException(java.lang.Throwable cause)
Create a service exception that includes an underlying cause exception.

Parameters:
cause -
Method Detail

toString

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

getErrorCode

public java.lang.String getErrorCode()
Returns:
The service-specific Error Code returned by the service, if a response is available. For example "AccessDenied", "InternalError" Null otherwise.

setErrorCode

public void setErrorCode(java.lang.String code)
Set the exception's error code; for internal use only.

Parameters:
code -

getErrorMessage

public java.lang.String getErrorMessage()
Returns:
The service-specific Error Message returned by the service, if a response is available. For example: "Access Denied", "We encountered an internal error. Please try again."

setErrorMessage

public void setErrorMessage(java.lang.String message)
Set the exception's error message; for internal use only.

Parameters:
message -

getErrorHostId

public java.lang.String getErrorHostId()
Returns:
The Error Host ID returned by the service, if a response is available. Null otherwise.

setErrorHostId

public void setErrorHostId(java.lang.String hostId)
Set the exception's host ID; for internal use only.

Parameters:
hostId -

getErrorRequestId

public java.lang.String getErrorRequestId()
Returns:
The Error Request ID returned by the service, if a response is available. Null otherwise.

setErrorRequestId

public void setErrorRequestId(java.lang.String requestId)
Set the exception's request ID; for internal use only.

Parameters:
requestId -

getXmlMessage

public java.lang.String getXmlMessage()
Returns:
The XML Error message returned by the service, if a response is available. Null otherwise.

getXmlMessageAsBuilder

public com.jamesmurty.utils.XMLBuilder getXmlMessageAsBuilder()
                                                       throws java.io.IOException,
                                                              javax.xml.parsers.ParserConfigurationException,
                                                              org.xml.sax.SAXException
Returns:
an XML error message returned by the services as an XMLBuilder object that allows for simple XPath querying via XMLBuilder.xpathFind(String), or null if no XML error document is available.
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

isParsedFromXmlMessage

public boolean isParsedFromXmlMessage()
Returns:
true if this exception contains information from an XML error document returned by a service, e.g. with error code details.

getResponseCode

public int getResponseCode()
Returns:
The HTTP Response Code returned by the service, if an HTTP response is available. For example: 401, 404, 500

setResponseCode

public void setResponseCode(int responseCode)
Set the exception's HTTP response code; for internal use only.

Parameters:
responseCode -

getResponseStatus

public java.lang.String getResponseStatus()
Returns:
The HTTP Status message returned by the service, if an HTTP response is available. For example: "Forbidden", "Not Found", "Internal Server Error"

setResponseStatus

public void setResponseStatus(java.lang.String responseStatus)
Set the exception's HTTP response status; for internal use only.

Parameters:
responseStatus -

getResponseDate

public java.lang.String getResponseDate()
Returns:
The exception's HTTP response date, if any.

setResponseDate

public void setResponseDate(java.lang.String responseDate)
Set the exception's HTTP response date; for internal use only.

Parameters:
responseDate -

getRequestVerb

public java.lang.String getRequestVerb()
Returns:
The HTTP Verb used in the request, if available. For example: "GET", "PUT", "DELETE"

setRequestVerb

public void setRequestVerb(java.lang.String requestVerb)
Set the exception's HTTP request verb; for internal use only.

Parameters:
requestVerb -

getRequestPath

public java.lang.String getRequestPath()
Returns:
the exception's HTTP request path; if any.

setRequestPath

public void setRequestPath(java.lang.String requestPath)
Set the exception's HTTP request path; for internal use only.

Parameters:
requestPath -

getRequestHost

public java.lang.String getRequestHost()
Returns:
the exception's HTTP request hostname; if any.

setRequestHost

public void setRequestHost(java.lang.String requestHost)
Set the exception's HTTP request hostname; for internal use only.

Parameters:
requestHost -

setRequestAndHostIds

public void setRequestAndHostIds(java.lang.String errorRequestId,
                                 java.lang.String errorHostId)
Allow the Request and Host Id fields to be populated in situations where this information is not available from an XML response error document. If there is no XML error response document, the RequestId and HostId will generally be available as the HTTP response headers x-amz-request-id and x-amz-id-2 respectively.

Parameters:
errorRequestId -
errorHostId -

getResponseHeaders

public java.util.Map<java.lang.String,java.lang.String> getResponseHeaders()
Returns:
the exception's HTTP response headers, if any.

setResponseHeaders

public void setResponseHeaders(java.util.Map<java.lang.String,java.lang.String> responseHeaders)
Set the exception's HTTP response headers; for internal use only.

Parameters:
responseHeaders -