HttpResponseException should have getContent() method #143
Labels
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 roy.hash...@gmail.com on July 26, 2012 10:58:17
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: http://code.google.com/p/google-http-java-client/issues/detail?id=143
The text was updated successfully, but these errors were encountered: