Search in sources :

Example 1 with HttpStatusCodeException

use of com.couchbase.client.core.error.HttpStatusCodeException in project couchbase-jvm-clients by couchbase.

the class AsyncCouchbaseHttpClient method exec.

private CompletableFuture<HttpResponse> exec(HttpMethod method, HttpTarget target, HttpPath path, CommonHttpOptions<?>.BuiltCommonHttpOptions options, Consumer<CoreHttpRequest.Builder> customizer) {
    CoreHttpRequest.Builder builder = new CoreHttpClient(core, target.coreTarget).newRequest(method, CoreHttpPath.path(path.formatted), options).bypassExceptionTranslation(true);
    options.headers().forEach(it -> builder.header(it.name, it.value));
    customizer.accept(builder);
    CoreHttpRequest req = builder.build();
    // request doesn't mysteriously time out while the service locator twiddles its thumbs.
    if (req.bucket() != null) {
        cluster.bucket(req.bucket());
    }
    return req.exec(core).thenApply(HttpResponse::new).exceptionally(t -> {
        HttpStatusCodeException statusCodeException = findCause(t, HttpStatusCodeException.class).orElseThrow(() -> propagate(t));
        return new HttpResponse(statusCodeException);
    });
}
Also used : CoreHttpRequest(com.couchbase.client.core.endpoint.http.CoreHttpRequest) CoreHttpClient(com.couchbase.client.core.endpoint.http.CoreHttpClient) HttpStatusCodeException(com.couchbase.client.core.error.HttpStatusCodeException)

Aggregations

CoreHttpClient (com.couchbase.client.core.endpoint.http.CoreHttpClient)1 CoreHttpRequest (com.couchbase.client.core.endpoint.http.CoreHttpRequest)1 HttpStatusCodeException (com.couchbase.client.core.error.HttpStatusCodeException)1