Skip to content

Commit

Permalink
Columnar: Update for Error Handling RFC revision #9
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Graham Pople <[email protected]>
  • Loading branch information
dnault committed Sep 17, 2024
1 parent 9771679 commit 6b2ff10
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 6b2ff10

Please sign in to comment.