emran396 / google-api-java-client

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

Http errors on executeMediaAndDownloadTo fail to throw GoogleJsonResponseException #782

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 reported on code.google.com by d...@google.com on 16 May 2013 at 9:31

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 17 May 2013 at 12:40

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 10 Jun 2013 at 1:30

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 21 Jun 2013 at 2:08

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 29 Jul 2013 at 6:07

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 27 Sep 2013 at 12:06