Skip to content

Commit

Permalink
Feat: no more exception if index not found
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbet committed Feb 26, 2025
1 parent c0fc153 commit be652c3
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public Map<String, Map<String, Object>> getMappings(String index) throws ArlasEx
return res;
} catch (IOException | ElasticsearchException e) {
processException(e, index);
return null;
return Map.of();
}
}

Expand Down Expand Up @@ -384,9 +384,11 @@ public CollectionReference getCollectionReferenceFromES(String index, String ref
}

private void processException(Exception e, String index) throws ArlasException {
if (e instanceof ResponseException) {
if (((ResponseException) e).getResponse().getStatusLine().getStatusCode() == 404) {
throw new NotFoundException("Index " + index + " does not exist.");
if (e instanceof ElasticsearchException exception) {
if (exception.response().error().type().equals("index_not_found_exception")) {
LOGGER.warn("Index {} does not exist.", index);
// We do not raise exception anymore, silent error in case of index_not_found_exception in ES
return;
}
}
LOGGER.warn("Exception while communicating with ES: " + e.getMessage(), e);
Expand Down

0 comments on commit be652c3

Please sign in to comment.