public class HttpResponseException extends IOException
Implementation is not thread safe.
Modifier and Type | Class and Description |
---|---|
static class |
HttpResponseException.Builder
Builder.
|
Modifier | Constructor and Description |
---|---|
|
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.
|
protected |
HttpResponseException(HttpResponseException.Builder builder) |
Modifier and Type | Method and Description |
---|---|
static StringBuilder |
computeMessageBuffer(HttpResponse response)
Returns an exception message string builder to use for the given HTTP response.
|
String |
getContent()
Returns the HTTP response content or
null for none. |
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() ). |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public HttpResponseException(HttpResponse response)
Callers of this constructor should call HttpResponse.disconnect()
after HttpResponseException
is instantiated. Example usage:
try { throw new HttpResponseException(response); } finally { response.disconnect(); }
response
- HTTP responseprotected HttpResponseException(HttpResponseException.Builder builder)
builder
- builderpublic final boolean isSuccessStatusCode()
>= 200 && < 300
(see getStatusCode()
).public final int getStatusCode()
0
for none.public final String getStatusMessage()
null
for none.public HttpHeaders getHeaders()
public final String getContent()
null
for none.public static StringBuilder computeMessageBuffer(HttpResponse response)
Copyright © 2011–2019 Google. All rights reserved.