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
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 Summary
ConstructorsConstructorDescriptionCreate 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
Modifier and TypeMethodDescriptionint
com.jamesmurty.utils.XMLBuilder
boolean
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.toString()
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Constructor Details
-
ServiceException
Create a service exception that includes the XML error document returned by service.- Parameters:
message
-xmlMessage
-
-
ServiceException
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
Create a service exception that includes a specific message and an optional underlying cause exception.- Parameters:
message
-cause
-
-
ServiceException
Create a service exception that includes a specific message.- Parameters:
message
-
-
ServiceException
Create a service exception that includes an underlying cause exception.- Parameters:
cause
-
-
-
Method Details
-
toString
-
getErrorCode
- Returns:
- The service-specific Error Code returned by the service, if a response is available. For example "AccessDenied", "InternalError" Null otherwise.
-
setErrorCode
Set the exception's error code; for internal use only.- Parameters:
code
-
-
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
Set the exception's error message; for internal use only.- Parameters:
message
-
-
getErrorHostId
- Returns:
- The Error Host ID returned by the service, if a response is available. Null otherwise.
-
setErrorHostId
Set the exception's host ID; for internal use only.- Parameters:
hostId
-
-
getErrorRequestId
- Returns:
- The Error Request ID returned by the service, if a response is available. Null otherwise.
-
setErrorRequestId
Set the exception's request ID; for internal use only.- Parameters:
requestId
-
-
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
- Returns:
- The HTTP Status message returned by the service, if an HTTP response is available. For example: "Forbidden", "Not Found", "Internal Server Error"
-
setResponseStatus
Set the exception's HTTP response status; for internal use only.- Parameters:
responseStatus
-
-
getResponseDate
- Returns:
- The exception's HTTP response date, if any.
-
setResponseDate
Set the exception's HTTP response date; for internal use only.- Parameters:
responseDate
-
-
getRequestVerb
- Returns:
- The HTTP Verb used in the request, if available. For example: "GET", "PUT", "DELETE"
-
setRequestVerb
Set the exception's HTTP request verb; for internal use only.- Parameters:
requestVerb
-
-
getRequestPath
- Returns:
- the exception's HTTP request path; if any.
-
setRequestPath
Set the exception's HTTP request path; for internal use only.- Parameters:
requestPath
-
-
getRequestHost
- Returns:
- the exception's HTTP request hostname; if any.
-
setRequestHost
Set the exception's HTTP request hostname; for internal use only.- Parameters:
requestHost
-
-
setRequestAndHostIds
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
- Returns:
- the exception's HTTP response headers, if any.
-
setResponseHeaders
Set the exception's HTTP response headers; for internal use only.- Parameters:
responseHeaders
-
-