I'm using the new Java 11 HTTP Client. I have a request like:
httpClient.sendAsync(request, discarding())
How to add a handler for HTTP errors? I need to log errors but I want to keep the request async.
Currently, HTTP errors like 400
or 500
, are silent.
I'd like to log the status code and response body on those occasions.
I suppose the CompletableFuture
is just like a promise, so the reply is not available there yet.