use of com.couchbase.client.core.error.context.KeyValueErrorContext in project couchbase-jvm-clients by couchbase.
the class MutateInAccessor method mutateIn.
public static CompletableFuture<MutateInResult> mutateIn(final Core core, final SubdocMutateRequest request, final String key, final PersistTo persistTo, final ReplicateTo replicateTo, final Boolean insertDocument, final JsonSerializer serializer) {
core.send(request);
final CompletableFuture<MutateInResult> mutateInResult = request.response().thenApply(response -> {
if (response.status().success()) {
return new MutateInResult(response.values(), response.cas(), response.mutationToken(), serializer);
}
final KeyValueErrorContext ctx = KeyValueErrorContext.completedRequest(request, response.status());
if (insertDocument && response.status() == ResponseStatus.EXISTS) {
throw new DocumentExistsException(ctx);
} else if (response.status() == ResponseStatus.SUBDOC_FAILURE && response.error().isPresent()) {
throw response.error().get();
}
throw keyValueStatusToException(request, response);
});
return wrapWithDurability(mutateInResult, key, persistTo, replicateTo, core, request, false);
}
Aggregations