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

java.lang.Object
  extended by java.util.AbstractMap<String,Object>
      extended by com.google.api.client.util.GenericData
          extended by com.google.api.client.json.GenericJson
              extended by com.google.api.client.googleapis.json.GoogleJsonError
All Implemented Interfaces:
Cloneable, Map<String,Object>

public class GoogleJsonError
extends com.google.api.client.json.GenericJson

Data class representing the Google JSON error response content, as documented for example in Error Messages in Google Buzz.

Parse the error response using parse(JsonFactory, HttpResponse). Sample usage:

    try {
      request.execute();
    } catch (HttpResponseException e) {
        GoogleJsonError errorResponse = GoogleJsonError.parse(factory, e.response);
        System.err.println(errorResponse.code + " Error: " + errorResponse.message);
        for (ErrorInfo error : errorResponse.errors) {
          System.err.println(factory.toString(error));
        }
    } catch (IOException e) {
...
    }
 

Since:
1.4
Author:
Yaniv Inbar

Nested Class Summary
static class GoogleJsonError.ErrorInfo
          Detailed error information.
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 int code
          Error code.
 List<GoogleJsonError.ErrorInfo> errors
          List of detailed errors.
 String message
          Error message.
 
Fields inherited from class com.google.api.client.json.GenericJson
jsonFactory
 
Fields inherited from class com.google.api.client.util.GenericData
unknownFields
 
Constructor Summary
GoogleJsonError()
           
 
Method Summary
static GoogleJsonError parse(com.google.api.client.json.JsonFactory jsonFactory, com.google.api.client.http.HttpResponse response)
          Parses the given error HTTP response using the given JSON factory.
 
Methods inherited from class com.google.api.client.json.GenericJson
clone, toString
 
Methods inherited from class com.google.api.client.util.GenericData
entrySet, get, getUnknownKeys, put, putAll, remove, set, setUnknownKeys
 
Methods inherited from class java.util.AbstractMap
clear, containsKey, containsValue, equals, hashCode, isEmpty, keySet, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

errors

public List<GoogleJsonError.ErrorInfo> errors
List of detailed errors.


code

public int code
Error code.


message

public String message
Error message.

Constructor Detail

GoogleJsonError

public GoogleJsonError()
Method Detail

parse

public static GoogleJsonError parse(com.google.api.client.json.JsonFactory jsonFactory,
                                    com.google.api.client.http.HttpResponse response)
                             throws IOException
Parses the given error HTTP response using the given JSON factory.

Parameters:
jsonFactory - JSON factory
response - HTTP response
Returns:
new instance of the Google JSON error information
Throws:
IOException


Copyright © 2010-2011 Google. All Rights Reserved.