com.google.api.client.http
Class HttpResponseException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.io.IOException
              extended by com.google.api.client.http.HttpResponseException
All Implemented Interfaces:
Serializable

public class HttpResponseException
extends IOException

Exception thrown when an error status code is detected in an HTTP response.

Since:
1.0
Author:
Yaniv Inbar
See Also:
Serialized Form

Constructor Summary
HttpResponseException(HttpResponse response)
          Constructor that constructs a detail message from the given HTTP response that includes the status code, status message and HTTP response content.
HttpResponseException(HttpResponse response, String message)
          Constructor that allows an alternative detail message to be used.
 
Method Summary
static StringBuilder computeMessageBuffer(HttpResponse response)
          Returns an exception message string builder to use for the given HTTP response.
 HttpHeaders getHeaders()
          Returns the HTTP response headers.
 int getStatusCode()
          Returns the HTTP status code or 0 for none.
 String getStatusMessage()
          Returns the HTTP status message or null for none.
 boolean isSuccessStatusCode()
          Returns whether received a successful HTTP status code >= 200 && < 300 (see getStatusCode()).
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HttpResponseException

public HttpResponseException(HttpResponse response)
Constructor that constructs a detail message from the given HTTP response that includes the status code, status message and HTTP response content.

Callers of this constructor should call HttpResponse.disconnect() after HttpResponseException is instantiated. Example usage:

     try {
       throw new HttpResponseException(response);
     } finally {
       response.disconnect();
     }
 

Parameters:
response - HTTP response

HttpResponseException

public HttpResponseException(HttpResponse response,
                             String message)
Constructor that allows an alternative detail message to be used.

Callers of this constructor should call HttpResponse.disconnect() after HttpResponseException is instantiated. Example usage:

     try {
       throw new HttpResponseException(response, message);
     } finally {
       response.disconnect();
     }
 

Parameters:
response - HTTP response
message - detail message to use or null for none
Since:
1.6
Method Detail

isSuccessStatusCode

public boolean isSuccessStatusCode()
Returns whether received a successful HTTP status code >= 200 && < 300 (see getStatusCode()).

Upgrade warning: Overriding this method is no longer supported, and will be made final in 1.10.

Since:
1.7

getStatusCode

public int getStatusCode()
Returns the HTTP status code or 0 for none.

Upgrade warning: Overriding this method is no longer supported, and will be made final in 1.10.

Since:
1.7

getStatusMessage

public final String getStatusMessage()
Returns the HTTP status message or null for none.

Since:
1.9

getHeaders

public HttpHeaders getHeaders()
Returns the HTTP response headers.

Since:
1.7

computeMessageBuffer

public static StringBuilder computeMessageBuffer(HttpResponse response)
Returns an exception message string builder to use for the given HTTP response.

Since:
1.7


Copyright © 2011-2012 Google. All Rights Reserved.