Google Data APIs Client Library (1.41.1)



com.google.gdata.util
Class ServiceException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by com.google.gdata.util.ServiceException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AppsForYourDomainException, AuthenticationException, BatchInterruptedException, EntityTooLargeException, InvalidEntryException, Kind.AdaptorException, NoLongerAvailableException, NotAcceptableException, NotImplementedException, NotModifiedException, OAuthProxyException, ParseException, PreconditionFailedException, RateLimitExceededException, RedirectRequiredException, ResourceNotFoundException, ResumableUploadException, ServiceConfigurationException, ServiceForbiddenException, ServiceUnavailableException, UnprocessableEntityException, UnsupportedMediaTypeException, VersionConflictException

public class ServiceException
extends java.lang.Exception

The ServiceException class is the base exception class used to indicate an error while processing a GDataRequest.

See Also:
Serialized Form

Constructor Summary
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)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServiceException

public ServiceException(java.lang.String message)

ServiceException

public ServiceException(java.lang.String message,
                        java.lang.Throwable cause)

ServiceException

public ServiceException(java.lang.Throwable cause)

ServiceException

public ServiceException(java.net.HttpURLConnection httpConn)
                 throws java.io.IOException
Initializes the ServiceException using the error response data from an HTTP connection. This constructor is used in the client library to approximately reconstitute the constructor as it appeared in the server.

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.

Parameters:
httpConn - is the http connection from which the error message (structured or simple) is read
Throws:
java.io.IOException - if network error receiving the error response

ServiceException

public ServiceException(ErrorContent errorCode)
Initializes the ServiceException using an 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).


ServiceException

public 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. Most ErrorContent instances are declared in a subclass of ErrorDomain containing all the errors for this GData domain (service or portion of service).

Method Detail

initCause

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.

Overrides:
initCause in class java.lang.Throwable

getHttpErrorCodeOverride

public int getHttpErrorCodeOverride()

setHttpErrorCodeOverride

public void setHttpErrorCodeOverride(int v)

getResponseContentType

public ContentType getResponseContentType()

setResponseContentType

public void setResponseContentType(ContentType v)

getResponseBody

public java.lang.String getResponseBody()

setResponseBody

public void setResponseBody(java.lang.String body)

setResponse

public void setResponse(ContentType contentType,
                        java.lang.String body)
Set HTTP response type and body simultaneously. They are inherently coupled together: a body without a content type is meaningless; a content type without a body is useless.


toXmlErrorMessage

public java.lang.String toXmlErrorMessage()
Converts the exception into a well-formated XML error message suitable for external uses.


toXmlErrorMessage

public java.lang.String toXmlErrorMessage(boolean includeDebugInfo)
Converts the exception into a well-formated XML error message suitable for external uses.

Parameters:
includeDebugInfo - if true, include debug information. Such error message should only be returned to internal clients.

getHttpHeaders

public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getHttpHeaders()
Return the internal HTTP headers in modifiable form.


getHttpHeader

public 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.

Parameters:
header - requested header name
Returns:
list of string values for the specified header or null if requested header is not found.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Throwable

getDomainName

public java.lang.String getDomainName()
Return error domain.

Defaults to "GData", indicating an error that has not yet been upgraded to the new architecture.


setDomain

public void setDomain(java.lang.String domain)
Set error domain.

Throws:
java.lang.NullPointerException - if domain is null.

getCodeName

public java.lang.String getCodeName()
Return error code.

Defaults to the class name of this.


setCode

public void setCode(java.lang.String code)
Set error code.

Throws:
java.lang.NullPointerException - if code is null.

getLocation

public java.lang.String getLocation()
Return error location.


getLocationType

public ErrorContent.LocationType getLocationType()
Return error location type.


setXpathLocation

public void setXpathLocation(java.lang.String location)
Set XPath-based error location. This must be a valid XPath expression sibling to the atom:entry element (or the atom:feed element if we are not in an entry).

Throws:
java.lang.NullPointerException - if location is null.

setHeaderLocation

public void setHeaderLocation(java.lang.String location)
Set header name for an error in a header.

Throws:
java.lang.NullPointerException - if location is null.

setLocation

public void setLocation(java.lang.String location)
Set generic error location.

Throws:
java.lang.NullPointerException - if location is null.

getInternalReason

public java.lang.String getInternalReason()
Return error internal reason.

Defaults to the message set at construction time.


getMessage

public java.lang.String getMessage()
Return message: same as getInternalReason.

Overrides:
getMessage in class java.lang.Throwable

setInternalReason

public void setInternalReason(java.lang.String internalReason)
Sets the internal reason of the error.

Throws:
java.lang.NullPointerException - if internalReason is null.

getExtendedHelp

public java.lang.String getExtendedHelp()
Return URI for extended help


setExtendedHelp

public void setExtendedHelp(java.lang.String extendedHelp)
Set URI for extended help.

Throws:
java.lang.NullPointerException - if extendedHelp is null.

getSendReport

public java.lang.String getSendReport()
Return URI to send report to.


setSendReport

public void setSendReport(java.lang.String sendReport)
Set URI to send report to.

Throws:
java.lang.NullPointerException - if sendReport is null.

getDebugInfo

public java.lang.String getDebugInfo()
Return debugging information. Defaults to the stack trace.


setDebugInfo

public void setDebugInfo(java.lang.String debugInfo)
Set debugging information.

Throws:
java.lang.NullPointerException - if debugInfo is null.

getSiblings

public java.util.List<ServiceException> getSiblings()
Return an unmodifiable copy of the sibling list.


addSibling

public ServiceException addSibling(ServiceException newbie)
Make and siblings, returning . All sibling exceptions are jointly converted to an error message when any of them are thrown.


matches

public boolean matches(ErrorContent code)
Return true if this ServiceException matches the specified ErrorContent in domain name and code name. Sibling exceptions are not checked.


matchesAny

public 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. If you want to know which particular ServiceException matched, call getSiblings() and examine the individual ServiceExceptions with matches(com.google.gdata.util.ErrorContent).


hasOAuthProxyResponse

public boolean hasOAuthProxyResponse()
Returns whether or not the request has OAuth Proxy-related headers.


getOAuthProxyResponse

public OAuthProxyResponse getOAuthProxyResponse()
Returns the headers related to the OAuth Proxy. If there are no OAuth Proxy related headers on the request, this method will return an OAuthProxyResponse object with null values for the headers. Use hasOAuthProxyResponse() to determine whether the request has OAuth Proxy information.