use of org.opensearch.client.opensearch._types.ErrorCause in project opensearch-java by opensearch-project.
the class ListResponse method serializeInternal.
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
if (ApiTypeHelper.isDefined(this.nodeFailures)) {
generator.writeKey("node_failures");
generator.writeStartArray();
for (ErrorCause item0 : this.nodeFailures) {
item0.serialize(generator, mapper);
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.nodes)) {
generator.writeKey("nodes");
generator.writeStartObject();
for (Map.Entry<String, TaskExecutingNode> item0 : this.nodes.entrySet()) {
generator.writeKey(item0.getKey());
item0.getValue().serialize(generator, mapper);
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.tasks)) {
generator.writeKey("tasks");
generator.writeStartObject();
for (Map.Entry<String, Info> item0 : this.tasks.entrySet()) {
generator.writeKey(item0.getKey());
item0.getValue().serialize(generator, mapper);
}
generator.writeEnd();
}
}
use of org.opensearch.client.opensearch._types.ErrorCause in project opensearch-java by opensearch-project.
the class BehaviorsTest method testAdditionalProperties.
@Test
public void testAdditionalProperties() {
// Check that additional property map is initialized even if not set explicitly
ErrorCause err = new ErrorCause.Builder().reason("Foo").type("Bar").build();
assertEquals(0, err.metadata().size());
err = new ErrorCause.Builder().reason("Some failure").type("Some type").metadata(MapBuilder.of("index", JsonData.of("test"), "retries", JsonData.of(1))).build();
err = checkJsonRoundtrip(err, "{\"index\":\"test\",\"retries\":1,\"type\":\"Some type\",\"reason\":\"Some failure\"}");
assertEquals("Some failure", err.reason());
assertEquals(1, err.metadata().get("retries").to(int.class).intValue());
assertEquals("test", err.metadata().get("index").to(String.class));
}
use of org.opensearch.client.opensearch._types.ErrorCause in project core-ng-project by neowu.
the class ElasticSearchImpl method searchException.
// convert elasticsearch-java client exception, to append detailed error message
SearchException searchException(ElasticsearchException e) {
ErrorCause causedBy = e.error().causedBy();
var builder = new StringBuilder(e.getMessage());
if (causedBy != null) {
builder.append("\nreason: ").append(causedBy.reason());
}
return new SearchException(builder.toString(), e);
}
use of org.opensearch.client.opensearch._types.ErrorCause in project core-ng-project by neowu.
the class ElasticSearchTypeImpl method validate.
private void validate(BulkResponse response) {
if (!response.errors())
return;
var builder = new CodeBuilder();
builder.append("bulk operation failed, errors=[\n");
for (BulkResponseItem item : response.items()) {
ErrorCause error = item.error();
if (error != null) {
builder.append("id={}, error={}, stackTrace={}\n", item.id(), error.reason(), error.stackTrace());
}
}
builder.append("]");
throw new SearchException(builder.build());
}
use of org.opensearch.client.opensearch._types.ErrorCause in project opensearch-java by opensearch-project.
the class CancelResponse method serializeInternal.
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
if (ApiTypeHelper.isDefined(this.nodeFailures)) {
generator.writeKey("node_failures");
generator.writeStartArray();
for (ErrorCause item0 : this.nodeFailures) {
item0.serialize(generator, mapper);
}
generator.writeEnd();
}
if (ApiTypeHelper.isDefined(this.nodes)) {
generator.writeKey("nodes");
generator.writeStartObject();
for (Map.Entry<String, TaskExecutingNode> item0 : this.nodes.entrySet()) {
generator.writeKey(item0.getKey());
item0.getValue().serialize(generator, mapper);
}
generator.writeEnd();
}
}
Aggregations