com.google.api.client.googleapis.json
Class GoogleJsonResponseException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.io.IOException
              extended by com.google.api.client.http.HttpResponseException
                  extended by com.google.api.client.googleapis.json.GoogleJsonResponseException
All Implemented Interfaces:
Serializable

public class GoogleJsonResponseException
extends HttpResponseException

Exception thrown when an error status code is detected in an HTTP response to a Google API that uses the JSON format, using the format specified in Error Messages in Google Buzz.

To get the structured details, use getDetails().

Since:
1.6
Author:
Yaniv Inbar
See Also:
Serialized Form

Method Summary
static GoogleJsonResponseException from(JsonFactory jsonFactory, HttpResponse response)
          Returns a new instance of GoogleJsonResponseException.
 GoogleJsonError getDetails()
          Returns the Google JSON error details or null for none (for example if response is not JSON).
 JsonFactory getJsonFactory()
          Returns the JSON factory.
 
Methods inherited from class com.google.api.client.http.HttpResponseException
computeMessage, getResponse
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getDetails

public final GoogleJsonError getDetails()
Returns the Google JSON error details or null for none (for example if response is not JSON).


getJsonFactory

public final JsonFactory getJsonFactory()
Returns the JSON factory.


from

public static GoogleJsonResponseException from(JsonFactory jsonFactory,
                                               HttpResponse response)
Returns a new instance of GoogleJsonResponseException.

If there is a JSON error response, it is parsed using GoogleJsonError, which can be inspected using getDetails(). Otherwise, response content (if any) is read and ignored. Either way, any content is already parsed, and trying to parse HttpResponse.getContent() of HttpResponseException.getResponse() will likely result in an IOException.

Parameters:
jsonFactory - JSON factory
response - HTTP response
Returns:
new instance of GoogleJsonResponseException


Copyright © 2010-2011 Google. All Rights Reserved.