From 6b2ff10c6aa8b76465cc1f9ded4e2ce7db3d15fc Mon Sep 17 00:00:00 2001 From: David Nault Date: Mon, 16 Sep 2024 11:40:23 -0700 Subject: [PATCH] Columnar: Update for Error Handling RFC revision #9 When selecting a query error to propagate as exception, prefer non-retriable errors. Change-Id: I3e27530e94e462dda27e62161d5c114861497a1a Reviewed-on: https://review.couchbase.org/c/couchbase-jvm-clients/+/216262 Tested-by: Build Bot Reviewed-by: Graham Pople --- .../com/couchbase/columnar/client/java/QueryExecutor.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/columnar-java-client/src/main/java/com/couchbase/columnar/client/java/QueryExecutor.java b/columnar-java-client/src/main/java/com/couchbase/columnar/client/java/QueryExecutor.java index ba330f68c..4e657de18 100644 --- a/columnar-java-client/src/main/java/com/couchbase/columnar/client/java/QueryExecutor.java +++ b/columnar-java-client/src/main/java/com/couchbase/columnar/client/java/QueryExecutor.java @@ -25,6 +25,7 @@ import com.couchbase.client.core.deps.com.fasterxml.jackson.databind.node.ObjectNode; import com.couchbase.client.core.error.CoreErrorCodeAndMessageException; import com.couchbase.client.core.error.CouchbaseException; +import com.couchbase.client.core.error.ErrorCodeAndMessage; import com.couchbase.client.core.error.InvalidArgumentException; import com.couchbase.client.core.error.UnambiguousTimeoutException; import com.couchbase.client.core.error.context.AnalyticsErrorContext; @@ -231,7 +232,12 @@ private static RuntimeException translateException(RuntimeException e) { return newAmbiguousTimeoutException(t.context()); } - return new QueryException(t.errors().get(0), t.context()); + ErrorCodeAndMessage primary = t.errors().stream() + .filter(it -> !it.retry()) + .findFirst() + .orElse(t.errors().get(0)); + + return new QueryException(primary, t.context()); } if (e instanceof com.couchbase.client.core.error.TimeoutException) {