Http errors on executeMediaAndDownloadTo fail to throw GoogleJsonResponseException #783
Labels
imported
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
From d...@google.com on May 16, 2013 14:31:54
Version of google-api-java-client (e.g. 1.15.0-rc)? @Head as of 20130516 Java environment (e.g. Java 6, Android 2.3, App Engine)? Java7 Describe the problem. Http errors (such as 404) during "get" requests which use the executeMediaAndDownloadTo method fail to throw the expected GoogleJsonResponseException, instead throwing a plain HttpResponseException. For example,
try {
gcs.objects().get("nonexistent-foo", "nonexistent-bar").executeMediaAndDownloadTo(out);
} catch (GoogleJsonResponseException e) {
// Expected.
assertEquals(404, e.getStatusCode())
}
will fail to catch any exception, instead leaking a plain HttpResponseException with status code 404.
Related methods, such as execute() and executeMedia() both correctly throw GoogleJsonResponseException. How would you expect it to be fixed? The HttpMediaDownloader should include logic similar to the enclosing AbstractGoogleClientRequest.buildHttpRequest, which sets up an HttpResponseInterceptor to allow throwing custom exceptions.
Original issue: http://code.google.com/p/google-api-java-client/issues/detail?id=782
The text was updated successfully, but these errors were encountered: