Skip to content

Commit

Permalink
Enhance exception messaging for OpenSearchStatusException
Browse files Browse the repository at this point in the history
  • Loading branch information
marevol committed Jan 14, 2024
1 parent d7af9d3 commit cd393c5
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
import org.opensearch.OpenSearchStatusException;
import org.opensearch.action.DocWriteRequest.OpType;
import org.opensearch.action.DocWriteResponse.Result;
import org.opensearch.action.admin.indices.create.CreateIndexResponse;
Expand Down Expand Up @@ -228,6 +229,8 @@ protected IndexResponse insert(final Object target, final OpType opType) {
.setOpType(opType).setRefreshPolicy(RefreshPolicy.IMMEDIATE).execute());
setId(target, id);
return response;
} catch (final OpenSearchStatusException 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 cd393c5

Please sign in to comment.