Skip to content

Commit

Permalink
Refine exception handling for data insertion conflicts to use Crawlin…
Browse files Browse the repository at this point in the history
…gAccessException
  • Loading branch information
marevol committed Apr 4, 2024
1 parent cbcf9c5 commit 143b9d6
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.codelibs.fess.crawler.client.FesenClient;
import org.codelibs.fess.crawler.entity.EsAccessResult;
import org.codelibs.fess.crawler.entity.EsAccessResultData;
import org.codelibs.fess.crawler.exception.CrawlingAccessException;
import org.codelibs.fess.crawler.exception.EsAccessException;
import org.codelibs.fess.crawler.util.EsResultList;
import org.joda.time.DateTimeZone;
Expand All @@ -69,6 +70,7 @@
import org.opensearch.cluster.metadata.MappingMetadata;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.index.IndexNotFoundException;
import org.opensearch.index.query.BoolQueryBuilder;
Expand Down Expand Up @@ -230,6 +232,9 @@ protected IndexResponse insert(final Object target, final OpType opType) {
setId(target, id);
return response;
} catch (final OpenSearchStatusException e) {
if (e.status() == RestStatus.CONFLICT) {
throw new CrawlingAccessException("[" + e.status() + "] Failed to insert " + id, e);
}
throw new EsAccessException("[" + e.status() + "] Failed to insert " + id, e);
} catch (final Exception e) {
throw new EsAccessException("Failed to insert " + id, e);
Expand Down

0 comments on commit 143b9d6

Please sign in to comment.