public class ServiceException
extends java.lang.Exception
Constructor and Description |
---|
ServiceException(ErrorContent errorCode)
Initializes the ServiceException using an
ErrorContent object that
encapsulates most of the information about the error. |
ServiceException(ErrorContent errorCode,
java.lang.Throwable cause)
Initializes the ServiceException using an
ErrorContent object that
encapsulates most of the information about the error, and an embedded
exception. |
ServiceException(java.net.HttpURLConnection httpConn)
Initializes the ServiceException using the error response data from an
HTTP connection.
|
ServiceException(java.lang.String message) |
ServiceException(java.lang.String message,
java.lang.Throwable cause) |
ServiceException(java.lang.Throwable cause) |
Modifier and Type | Method and Description |
---|---|
ServiceException |
addSibling(ServiceException newbie)
Make and siblings, returning .
|
java.lang.String |
getCodeName()
Return error code.
|
java.lang.String |
getDebugInfo()
Return debugging information.
|
java.lang.String |
getDomainName()
Return error domain.
|
java.lang.String |
getExtendedHelp()
Return URI for extended help
|
int |
getHttpErrorCodeOverride() |
java.util.List<java.lang.String> |
getHttpHeader(java.lang.String header)
Return the value for requested internal HTTP header or
null if
the header is not present. |
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getHttpHeaders()
Return the internal HTTP headers in modifiable form.
|
java.lang.String |
getInternalReason()
Return error internal reason.
|
java.lang.String |
getLocation()
Return error location.
|
ErrorContent.LocationType |
getLocationType()
Return error location type.
|
java.lang.String |
getMessage()
Return message: same as getInternalReason.
|
OAuthProxyResponse |
getOAuthProxyResponse()
Returns the headers related to the OAuth Proxy.
|
java.lang.String |
getResponseBody() |
ContentType |
getResponseContentType() |
java.lang.String |
getSendReport()
Return URI to send report to.
|
java.util.List<ServiceException> |
getSiblings()
Return an unmodifiable copy of the sibling list.
|
boolean |
hasOAuthProxyResponse()
Returns whether or not the request has OAuth Proxy-related headers.
|
java.lang.Throwable |
initCause(java.lang.Throwable cause) |
boolean |
matches(ErrorContent code)
Return true if this ServiceException matches the specified
ErrorContent in domain name and code name. |
boolean |
matchesAny(ErrorContent errorCode)
Return true if this ServiceException or any of its sibling exceptions
matches the specified
ErrorContent in domain name and code name. |
void |
setCode(java.lang.String code)
Set error code.
|
void |
setDebugInfo(java.lang.String debugInfo)
Set debugging information.
|
void |
setDomain(java.lang.String domain)
Set error domain.
|
void |
setExtendedHelp(java.lang.String extendedHelp)
Set URI for extended help.
|
void |
setHeaderLocation(java.lang.String location)
Set header name for an error in a header.
|
void |
setHttpErrorCodeOverride(int v) |
void |
setInternalReason(java.lang.String internalReason)
Sets the internal reason of the error.
|
void |
setLocation(java.lang.String location)
Set generic error location.
|
void |
setResponse(ContentType contentType,
java.lang.String body)
Set HTTP response type and body simultaneously.
|
void |
setResponseBody(java.lang.String body) |
void |
setResponseContentType(ContentType v) |
void |
setSendReport(java.lang.String sendReport)
Set URI to send report to.
|
void |
setXpathLocation(java.lang.String location)
Set XPath-based error location.
|
java.lang.String |
toString() |
java.lang.String |
toXmlErrorMessage()
Converts the exception into a well-formated XML error
message suitable for external uses.
|
java.lang.String |
toXmlErrorMessage(boolean includeDebugInfo)
Converts the exception into a well-formated XML error
message suitable for external uses.
|
public ServiceException(java.lang.String message)
public ServiceException(java.lang.String message, java.lang.Throwable cause)
public ServiceException(java.lang.Throwable cause)
public ServiceException(java.net.HttpURLConnection httpConn) throws java.io.IOException
This constructor uses a ServiceExceptionInitializer to do the work of parsing the connection and calling our setters to initialize our fields. The initializer object may also create sibling ServiceExceptions.
httpConn
- is the http connection from which the error message
(structured or simple) is readjava.io.IOException
- if network error receiving the error responsepublic ServiceException(ErrorContent errorCode)
ErrorContent
object that
encapsulates most of the information about the error. Most ErrorContent
instances are declared in a subclass of ErrorDomain
containing all
the errors for a GData domain (service or portion of service).public ServiceException(ErrorContent errorCode, java.lang.Throwable cause)
ErrorContent
object that
encapsulates most of the information about the error, and an embedded
exception. Most ErrorContent instances are declared in a subclass of
ErrorDomain
containing all the errors for this GData domain
(service or portion of service).public java.lang.Throwable initCause(java.lang.Throwable cause)
If cause
is a ServiceException
, it is added to
the list of siblings so that the original exception appears when
using XML error output.
initCause
in class java.lang.Throwable
public int getHttpErrorCodeOverride()
public void setHttpErrorCodeOverride(int v)
public ContentType getResponseContentType()
public void setResponseContentType(ContentType v)
public java.lang.String getResponseBody()
public void setResponseBody(java.lang.String body)
public void setResponse(ContentType contentType, java.lang.String body)
public java.lang.String toXmlErrorMessage()
public java.lang.String toXmlErrorMessage(boolean includeDebugInfo)
includeDebugInfo
- if true
, include debug information.
Such error message should only be returned to internal clients.public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getHttpHeaders()
public java.util.List<java.lang.String> getHttpHeader(java.lang.String header)
null
if
the header is not present.header
- requested header namenull
if
requested header is not found.public java.lang.String toString()
toString
in class java.lang.Throwable
public java.lang.String getDomainName()
Defaults to "GData", indicating an error that has not yet been upgraded to the new architecture.
public void setDomain(java.lang.String domain)
java.lang.NullPointerException
- if domain
is null
.public java.lang.String getCodeName()
Defaults to the class name of this
.
public void setCode(java.lang.String code)
java.lang.NullPointerException
- if code
is null
.public java.lang.String getLocation()
public ErrorContent.LocationType getLocationType()
public void setXpathLocation(java.lang.String location)
java.lang.NullPointerException
- if location
is null
.public void setHeaderLocation(java.lang.String location)
java.lang.NullPointerException
- if location
is null
.public void setLocation(java.lang.String location)
java.lang.NullPointerException
- if location
is null
.public java.lang.String getInternalReason()
Defaults to the message set at construction time.
public java.lang.String getMessage()
getMessage
in class java.lang.Throwable
public void setInternalReason(java.lang.String internalReason)
java.lang.NullPointerException
- if internalReason
is null
.public java.lang.String getExtendedHelp()
public void setExtendedHelp(java.lang.String extendedHelp)
java.lang.NullPointerException
- if extendedHelp
is null
.public java.lang.String getSendReport()
public void setSendReport(java.lang.String sendReport)
java.lang.NullPointerException
- if sendReport
is null
.public java.lang.String getDebugInfo()
public void setDebugInfo(java.lang.String debugInfo)
java.lang.NullPointerException
- if debugInfo
is null
.public java.util.List<ServiceException> getSiblings()
public ServiceException addSibling(ServiceException newbie)
public boolean matches(ErrorContent code)
ErrorContent
in domain name and code name. Sibling exceptions are
not checked.public boolean matchesAny(ErrorContent errorCode)
ErrorContent
in domain name and code name.
If you want to know which particular ServiceException matched, call
getSiblings()
and examine the individual ServiceExceptions with
matches(com.google.gdata.util.ErrorContent)
.public boolean hasOAuthProxyResponse()
public OAuthProxyResponse getOAuthProxyResponse()
OAuthProxyResponse
object with null values for the headers. Use
hasOAuthProxyResponse()
to determine whether the request has
OAuth Proxy information.