thomasmueller commented on code in PR #670:
URL: https://github.com/apache/jackrabbit-oak/pull/670#discussion_r949340989


##########
oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/async/ElasticAsyncQueryException.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.index.elastic.query.async;
+
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
+
+public class ElasticAsyncQueryException extends RuntimeException {
+
+    private final String esQuery;
+
+    public ElasticAsyncQueryException(Throwable cause, String esQuery) {
+        super(cause);
+
+        this.esQuery = esQuery;
+    }
+
+    @Override
+    public String getMessage() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(String.format("Error retrieving data for ES query:\n\t%s", 
esQuery));
+        if (getCause() instanceof ElasticsearchException) {
+            ElasticsearchException esException = (ElasticsearchException) 
getCause();
+            sb.append("\n:: Elasticsearch response status: 
").append(esException.status()).append(", message: 
").append(esException.getMessage());
+            esException.error().rootCause().forEach(ec -> sb.append("\n\t* 
caused by ").append(ec.type()).append(": ").append(ec.reason()));

Review Comment:
   I wonder if we need to protect against error() being null, rootCause() 
returning null, and so on.



##########
oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/async/ElasticResultRowAsyncIterator.java:
##########
@@ -336,13 +336,10 @@ public void onFailure(Throwable t) {
                     System.currentTimeMillis() - searchStartTime);
             // Check in case errorRef is already set - this seems unlikely 
since we close the scanner once we hit failure.
             // But still, in case this do happen, we will log a warn.
-            Throwable error = errorRef.getAndSet(t);
+            Throwable error = errorRef.getAndSet(new 
ElasticAsyncQueryException(t, ElasticIndexUtils.toString(query)));
             if (error != null) {
                 LOG.warn("Error reference for async iterator was previously 
set to {}. It has now been reset to new error {}", error.getMessage(), 
t.getMessage());
             }
-
-            LOG.error("Error retrieving data for jcr query [{}] :: 
Corresponding ES query {} : closing scanner, notifying listeners",

Review Comment:
   So we no longer log this, why? Isn't there a risk that we don't log it at 
all in some cases? Unless I'm mistaken this code was changed recently, because 
we didn't have sufficient log messages...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to