public class ServiceException extends 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,
Throwable cause)
Initializes the ServiceException using an
ErrorContent object that
encapsulates most of the information about the error, and an embedded
exception. |
ServiceException(HttpURLConnection httpConn)
Initializes the ServiceException using the error response data from an
HTTP connection.
|
ServiceException(String message) |
ServiceException(String message,
Throwable cause) |
ServiceException(Throwable cause) |
| Modifier and Type | Method and Description |
|---|---|
ServiceException |
addSibling(ServiceException newbie)
Make and siblings, returning .
|
String |
getCodeName()
Return error code.
|
String |
getDebugInfo()
Return debugging information.
|
String |
getDomainName()
Return error domain.
|
String |
getExtendedHelp()
Return URI for extended help
|
int |
getHttpErrorCodeOverride() |
List<String> |
getHttpHeader(String header)
Return the value for requested internal HTTP header or
null if
the header is not present. |
Map<String,List<String>> |
getHttpHeaders()
Return the internal HTTP headers in modifiable form.
|
String |
getInternalReason()
Return error internal reason.
|
String |
getLocation()
Return error location.
|
ErrorContent.LocationType |
getLocationType()
Return error location type.
|
String |
getMessage()
Return message: same as getInternalReason.
|
OAuthProxyResponse |
getOAuthProxyResponse()
Returns the headers related to the OAuth Proxy.
|
String |
getResponseBody() |
ContentType |
getResponseContentType() |
String |
getSendReport()
Return URI to send report to.
|
List<ServiceException> |
getSiblings()
Return an unmodifiable copy of the sibling list.
|
boolean |
hasOAuthProxyResponse()
Returns whether or not the request has OAuth Proxy-related headers.
|
Throwable |
initCause(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(String code)
Set error code.
|
void |
setDebugInfo(String debugInfo)
Set debugging information.
|
void |
setDomain(String domain)
Set error domain.
|
void |
setExtendedHelp(String extendedHelp)
Set URI for extended help.
|
void |
setHeaderLocation(String location)
Set header name for an error in a header.
|
void |
setHttpErrorCodeOverride(int v) |
void |
setInternalReason(String internalReason)
Sets the internal reason of the error.
|
void |
setLocation(String location)
Set generic error location.
|
void |
setResponse(ContentType contentType,
String body)
Set HTTP response type and body simultaneously.
|
void |
setResponseBody(String body) |
void |
setResponseContentType(ContentType v) |
void |
setSendReport(String sendReport)
Set URI to send report to.
|
void |
setXpathLocation(String location)
Set XPath-based error location.
|
String |
toString() |
String |
toXmlErrorMessage()
Converts the exception into a well-formated XML error
message suitable for external uses.
|
String |
toXmlErrorMessage(boolean includeDebugInfo)
Converts the exception into a well-formated XML error
message suitable for external uses.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, printStackTrace, printStackTrace, printStackTrace, setStackTracepublic ServiceException(String message)
public ServiceException(Throwable cause)
public ServiceException(HttpURLConnection httpConn) throws 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 readIOException - 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, 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 Throwable initCause(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.
public int getHttpErrorCodeOverride()
public void setHttpErrorCodeOverride(int v)
public ContentType getResponseContentType()
public void setResponseContentType(ContentType v)
public String getResponseBody()
public void setResponseBody(String body)
public void setResponse(ContentType contentType, String body)
public String toXmlErrorMessage()
public String toXmlErrorMessage(boolean includeDebugInfo)
includeDebugInfo - if true, include debug information.
Such error message should only be returned to internal clients.public Map<String,List<String>> getHttpHeaders()
public List<String> getHttpHeader(String header)
null if
the header is not present.header - requested header namenull if
requested header is not found.public String getDomainName()
Defaults to "GData", indicating an error that has not yet been upgraded to the new architecture.
public void setDomain(String domain)
NullPointerException - if domain is null.public String getCodeName()
Defaults to the class name of this.
public void setCode(String code)
NullPointerException - if code is null.public String getLocation()
public ErrorContent.LocationType getLocationType()
public void setXpathLocation(String location)
NullPointerException - if location is null.public void setHeaderLocation(String location)
NullPointerException - if location is null.public void setLocation(String location)
NullPointerException - if location is null.public String getInternalReason()
Defaults to the message set at construction time.
public String getMessage()
getMessage in class Throwablepublic void setInternalReason(String internalReason)
NullPointerException - if internalReason is null.public String getExtendedHelp()
public void setExtendedHelp(String extendedHelp)
NullPointerException - if extendedHelp is null.public String getSendReport()
public void setSendReport(String sendReport)
NullPointerException - if sendReport is null.public String getDebugInfo()
public void setDebugInfo(String debugInfo)
NullPointerException - if debugInfo is null.public 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.Copyright © 2012. All Rights Reserved.