Package org.jets3t.service
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 byStorageService
and related utilities. This exception can hold useful additional information about errors that occur when communicating with a service.- Author:
- James Murty
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ServiceException()
Create a service exception without any useful information.ServiceException(String message)
Create a service exception that includes a specific message.ServiceException(String message, String xmlMessage)
Create a service exception that includes the XML error document returned by service.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.ServiceException(String message, Throwable cause)
Create a service exception that includes a specific message and an optional underlying cause exception.ServiceException(Throwable cause)
Create a service exception that includes an underlying cause exception.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getErrorCode()
String
getErrorHostId()
String
getErrorMessage()
String
getErrorRequestId()
String
getRequestHost()
String
getRequestPath()
String
getRequestVerb()
int
getResponseCode()
String
getResponseDate()
Map<String,String>
getResponseHeaders()
String
getResponseStatus()
String
getXmlMessage()
com.jamesmurty.utils.XMLBuilder
getXmlMessageAsBuilder()
boolean
isParsedFromXmlMessage()
void
setErrorCode(String code)
Set the exception's error code; for internal use only.void
setErrorHostId(String hostId)
Set the exception's host ID; for internal use only.void
setErrorMessage(String message)
Set the exception's error message; for internal use only.void
setErrorRequestId(String requestId)
Set the exception's request ID; for internal use only.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.void
setRequestHost(String requestHost)
Set the exception's HTTP request hostname; for internal use only.void
setRequestPath(String requestPath)
Set the exception's HTTP request path; for internal use only.void
setRequestVerb(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(String responseDate)
Set the exception's HTTP response date; for internal use only.void
setResponseHeaders(Map<String,String> responseHeaders)
Set the exception's HTTP response headers; for internal use only.void
setResponseStatus(String responseStatus)
Set the exception's HTTP response status; for internal use only.String
toString()
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
-
-
-
Constructor Detail
-
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 Detail
-
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 viaXMLBuilder.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 headersx-amz-request-id
andx-amz-id-2
respectively.- Parameters:
errorRequestId
-errorHostId
-
-
getResponseHeaders
public Map<String,String> getResponseHeaders()
- Returns:
- the exception's HTTP response headers, if any.
-
-