artiya4u / google-http-java-client

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

HttpResponseException should have getContent() method #143

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-http-java-client (e.g. 1.5.0-beta)?
1.10

Java environment (e.g. Java 6, Android 2.3, App Engine)?
Any

Describe the problem.
When this exception is thrown, the only way to get the HttpResponse content is 
to parse the exception message.  The format of the exception message is simple 
but is not documented.

In my case, I need to catch an HttpResponseException that results from an 
OAuth2 exchange and examine the JSON returned to determine what happened.  I 
have to extract the JSON from the exception message before applying a JSON 
parser.  If the undocumented format of the exception message changes, my code 
will also break.

How would you expect it to be fixed?
This could be fixed simply by documenting the format of the String returned by 
getMessage() and defining it as part of the API.  It would be much better, 
however, to add a getContent() method that returns only the content.  This is 
the strategy recommended in Effective Java Item 10: Always override toString.

Original issue reported on code.google.com by roy.hash...@gmail.com on 26 Jul 2012 at 5:58

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 2 Oct 2012 at 1:37

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 13 Dec 2012 at 2:38

GoogleCodeExporter commented 9 years ago
https://codereview.appspot.com/7092048/

Original comment by yan...@google.com on 12 Jan 2013 at 3:46

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 18 Jan 2013 at 3:11