public class FailedResponse<T> extends Object implements HttpResponse<T>
| Constructor and Description |
|---|
FailedResponse(Exception e)
Build a elaborate lie from a failure.
|
| Modifier and Type | Method and Description |
|---|---|
T |
getBody() |
Cookies |
getCookies()
return a cookie collection parse from the set-cookie header
|
Headers |
getHeaders() |
Optional<UnirestParsingException> |
getParsingError()
If the transformation to the body failed by an exception it will be kept here
|
HttpRequestSummary |
getRequestSummary() |
int |
getStatus()
Returns a 542, which is nothing and a lie.
|
String |
getStatusText()
a error message of the exception
|
<E> HttpResponse<T> |
ifFailure(Class<? extends E> errorClass,
Consumer<HttpResponse<E>> consumer)
If the response was NOT a 200-series response or a mapping exception happened.
|
HttpResponse<T> |
ifFailure(Consumer<HttpResponse<T>> consumer)
If the response was NOT a 200-series response or a mapping exception happened.
|
HttpResponse<T> |
ifSuccess(Consumer<HttpResponse<T>> consumer)
If the response was a 200-series response.
|
boolean |
isSuccess()
is this a success? Obvs no!
|
<V> HttpResponse<V> |
map(Function<T,V> func)
Map the Response into another response with a different body
|
<V> V |
mapBody(Function<T,V> func)
Map the body into another type
|
<E> E |
mapError(Class<? extends E> errorClass)
Map the body to an error object, however because the body in this case is always
null this will always return null
|
public FailedResponse(Exception e)
e - where it all went wrong.public int getStatus()
getStatus in interface HttpResponse<T>public String getStatusText()
getStatusText in interface HttpResponse<T>public Headers getHeaders()
getHeaders in interface HttpResponse<T>public T getBody()
getBody in interface HttpResponse<T>public Optional<UnirestParsingException> getParsingError()
HttpResponsegetParsingError in interface HttpResponse<T>public <V> V mapBody(Function<T,V> func)
HttpResponsemapBody in interface HttpResponse<T>V - always nullfunc - a function to transform a body type to something else.public <V> HttpResponse<V> map(Function<T,V> func)
HttpResponsemap in interface HttpResponse<T>V - always nullfunc - a function to transform a body type to something else.public HttpResponse<T> ifSuccess(Consumer<HttpResponse<T>> consumer)
HttpResponseifSuccess in interface HttpResponse<T>consumer - a function to consume a successful HttpResponse.
This is never called in this case.public HttpResponse<T> ifFailure(Consumer<HttpResponse<T>> consumer)
HttpResponseifFailure in interface HttpResponse<T>consumer - a function to consume a failed HttpResponse
always called in this casepublic <E> HttpResponse<T> ifFailure(Class<? extends E> errorClass, Consumer<HttpResponse<E>> consumer)
HttpResponseifFailure in interface HttpResponse<T>E - the type of error class to map the bodyerrorClass - the class to transform the body to. However as the body is null
in this case it will also be nullconsumer - a function to consume a failed HttpResponse
always called in this casepublic boolean isSuccess()
isSuccess in interface HttpResponse<T>public <E> E mapError(Class<? extends E> errorClass)
mapError in interface HttpResponse<T>E - the error typeerrorClass - the class for the errorpublic Cookies getCookies()
HttpResponsegetCookies in interface HttpResponse<T>public HttpRequestSummary getRequestSummary()
getRequestSummary in interface HttpResponse<T>Copyright © 2023. All rights reserved.