achrefB3 / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

Google API JSON error response #184

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
External references, such as a standards document, or specification?

http://code.google.com/apis/buzz/v1/using_rest.html#errors

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.2, or All)?

All

Please describe the feature requested.

Google APIs use a specific JSON error response format.  The library should have 
a data class to help parse it.  It should look something like this:

public class ErrorResponse {
 @Key Error error;
}

public class Error extends GenericJson {
 @Key ArrayList<ErrorInfo> errors;
 @Key int code;
 @Key String message;
}

public class ErrorInfo extends GenericJson {
 @Key String domain;
 @Key String reason;
 @Key String message;
 @Key String location;
 @Key String locationType;
}

Then it could be used as in this example:

try {
...
} catch (HttpResponseException e) {
 ErrorResponse errorResponse = e.response.parseAs(ErrorResponse);
 ....
}

Original issue reported on code.google.com by yan...@google.com on 18 Apr 2011 at 1:38

GoogleCodeExporter commented 9 years ago
Better reference:
http://google-styleguide.googlecode.com/svn/trunk/jsoncstyleguide.xml#Reserved_P
roperty_Names_in_the_error_object

Original comment by yan...@google.com on 18 Apr 2011 at 3:54

GoogleCodeExporter commented 9 years ago
http://codereview.appspot.com/4453046/

Original comment by yan...@google.com on 27 Apr 2011 at 6:32

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 27 Apr 2011 at 8:18