Class ServiceException

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

public class ServiceException extends 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.
Author:
James Murty
See Also:
  • Constructor Details

    • ServiceException

      public ServiceException(String message, String xmlMessage)
      Create a service exception that includes the XML error document returned by service.
      Parameters:
      message -
      xmlMessage -
    • ServiceException

      public ServiceException(String message, String xmlMessage, 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(String message, Throwable cause)
      Create a service exception that includes a specific message and an optional underlying cause exception.
      Parameters:
      message -
      cause -
    • ServiceException

      public ServiceException(String message)
      Create a service exception that includes a specific message.
      Parameters:
      message -
    • ServiceException

      public ServiceException(Throwable cause)
      Create a service exception that includes an underlying cause exception.
      Parameters:
      cause -
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Throwable
    • getErrorCode

      public 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(String code)
      Set the exception's error code; for internal use only.
      Parameters:
      code -
    • getErrorMessage

      public 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(String message)
      Set the exception's error message; for internal use only.
      Parameters:
      message -
    • getErrorHostId

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

      public void setErrorHostId(String hostId)
      Set the exception's host ID; for internal use only.
      Parameters:
      hostId -
    • getErrorRequestId

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

      public void setErrorRequestId(String requestId)
      Set the exception's request ID; for internal use only.
      Parameters:
      requestId -
    • getXmlMessage

      public 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 IOException, ParserConfigurationException, 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:
      IOException
      ParserConfigurationException
      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 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(String responseStatus)
      Set the exception's HTTP response status; for internal use only.
      Parameters:
      responseStatus -
    • getResponseDate

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

      public void setResponseDate(String responseDate)
      Set the exception's HTTP response date; for internal use only.
      Parameters:
      responseDate -
    • getRequestVerb

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

      public void setRequestVerb(String requestVerb)
      Set the exception's HTTP request verb; for internal use only.
      Parameters:
      requestVerb -
    • getRequestPath

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

      public void setRequestPath(String requestPath)
      Set the exception's HTTP request path; for internal use only.
      Parameters:
      requestPath -
    • getRequestHost

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

      public void setRequestHost(String requestHost)
      Set the exception's HTTP request hostname; for internal use only.
      Parameters:
      requestHost -
    • setRequestAndHostIds

      public void setRequestAndHostIds(String errorRequestId, 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 Map<String,String> getResponseHeaders()
      Returns:
      the exception's HTTP response headers, if any.
    • setResponseHeaders

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