for (ElasticsearchException rootCause : rootCauses) { builder.startObject(); rootCause.toXContent(builder, new DelegatingMapParams(singletonMap(REST_EXCEPTION_SKIP_CAUSE, "true"), params)); builder.endObject();
for (ElasticsearchException rootCause : rootCauses) { builder.startObject(); rootCause.toXContent(builder, new DelegatingMapParams(singletonMap(REST_EXCEPTION_SKIP_CAUSE, "true"), params)); builder.endObject();
for (ElasticsearchException rootCause : rootCauses) { builder.startObject(); rootCause.toXContent(builder, new DelegatingMapParams(singletonMap(REST_EXCEPTION_SKIP_CAUSE, "true"), params)); builder.endObject();
final ToXContent.Params params; if (channel.request().paramAsBoolean("error_trace", !ElasticsearchException.REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT)) { params = new ToXContent.DelegatingMapParams(Collections.singletonMap(ElasticsearchException.REST_EXCEPTION_SKIP_STACK_TRACE, "false"), channel.request()); } else { if (status.getStatus() < 500) { for (ElasticsearchException rootCause : rootCauses){ builder.startObject(); rootCause.toXContent(builder, new ToXContent.DelegatingMapParams(Collections.singletonMap(ElasticsearchException.REST_EXCEPTION_SKIP_CAUSE, "true"), params)); builder.endObject();
for (ElasticsearchException rootCause : rootCauses) { builder.startObject(); rootCause.toXContent(builder, new DelegatingMapParams(singletonMap(REST_EXCEPTION_SKIP_CAUSE, "true"), params)); builder.endObject();
Params extendedParams = new DelegatingMapParams(extraParams, params);
private static XContentBuilder build(RestChannel channel, RestStatus status, Exception e) throws IOException { ToXContent.Params params = channel.request(); if (params.paramAsBoolean("error_trace", !REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT)) { params = new ToXContent.DelegatingMapParams(singletonMap(REST_EXCEPTION_SKIP_STACK_TRACE, "false"), params); } else if (e != null) { Supplier<?> messageSupplier = () -> new ParameterizedMessage("path: {}, params: {}", channel.request().rawPath(), channel.request().params()); if (status.getStatus() < 500) { SUPPRESSED_ERROR_LOGGER.debug(messageSupplier, e); } else { SUPPRESSED_ERROR_LOGGER.warn(messageSupplier, e); } } XContentBuilder builder = channel.newErrorBuilder().startObject(); ElasticsearchException.generateFailureXContent(builder, params, e, channel.detailedErrorsEnabled()); builder.field(STATUS, status.getStatus()); builder.endObject(); return builder; }
private static XContentBuilder build(RestChannel channel, RestStatus status, Exception e) throws IOException { ToXContent.Params params = channel.request(); if (params.paramAsBoolean("error_trace", !REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT)) { params = new ToXContent.DelegatingMapParams(singletonMap(REST_EXCEPTION_SKIP_STACK_TRACE, "false"), params); } else if (e != null) { Supplier<?> messageSupplier = () -> new ParameterizedMessage("path: {}, params: {}", channel.request().rawPath(), channel.request().params()); if (status.getStatus() < 500) { SUPPRESSED_ERROR_LOGGER.debug(messageSupplier, e); } else { SUPPRESSED_ERROR_LOGGER.warn(messageSupplier, e); } } XContentBuilder builder = channel.newErrorBuilder().startObject(); ElasticsearchException.generateFailureXContent(builder, params, e, channel.detailedErrorsEnabled()); builder.field(STATUS, status.getStatus()); builder.endObject(); return builder; }
private static XContentBuilder build(RestChannel channel, RestStatus status, Exception e) throws IOException { ToXContent.Params params = channel.request(); if (params.paramAsBoolean("error_trace", !REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT)) { params = new ToXContent.DelegatingMapParams(singletonMap(REST_EXCEPTION_SKIP_STACK_TRACE, "false"), params); } else if (e != null) { Supplier<?> messageSupplier = () -> new ParameterizedMessage("path: {}, params: {}", channel.request().rawPath(), channel.request().params()); if (status.getStatus() < 500) { SUPPRESSED_ERROR_LOGGER.debug(messageSupplier, e); } else { SUPPRESSED_ERROR_LOGGER.warn(messageSupplier, e); } } XContentBuilder builder = channel.newErrorBuilder().startObject(); ElasticsearchException.generateFailureXContent(builder, params, e, channel.detailedErrorsEnabled()); builder.field(STATUS, status.getStatus()); builder.endObject(); return builder; }
public static void renderThrowable(XContentBuilder builder, Params params, Throwable t) throws IOException { builder.startObject("error"); final ElasticsearchException[] rootCauses = ElasticsearchException.guessRootCauses(t); builder.field("root_cause"); builder.startArray(); for (ElasticsearchException rootCause : rootCauses){ builder.startObject(); rootCause.toXContent(builder, new ToXContent.DelegatingMapParams(Collections.singletonMap(ElasticsearchException.REST_EXCEPTION_SKIP_CAUSE, "true"), params)); builder.endObject(); } builder.endArray(); ElasticsearchException.toXContent(builder, params, t); builder.endObject(); } }
@Override public RestResponse buildResponse(GetIndexTemplatesResponse getIndexTemplatesResponse, XContentBuilder builder) throws Exception { boolean templateExists = getIndexTemplatesResponse.getIndexTemplates().size() > 0; Map<String, String> paramsMap = Maps.newHashMap(); paramsMap.put("reduce_mappings", "true"); ToXContent.Params params = new ToXContent.DelegatingMapParams(paramsMap, request); builder.startObject(); for (IndexTemplateMetaData indexTemplateMetaData : getIndexTemplatesResponse.getIndexTemplates()) { IndexTemplateMetaData.Builder.toXContent(indexTemplateMetaData, builder, params); } builder.endObject(); RestStatus restStatus = (templateExists || implicitAll) ? OK : NOT_FOUND; return new BytesRestResponse(restStatus, builder); } });
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { params = new ToXContent.DelegatingMapParams(singletonMap("reduce_mappings", "true"), params); builder.startObject(); for (IndexTemplateMetaData indexTemplateMetaData : getIndexTemplates()) { IndexTemplateMetaData.Builder.toXContent(indexTemplateMetaData, builder, params); } builder.endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { params = new ToXContent.DelegatingMapParams(singletonMap("reduce_mappings", "true"), params); builder.startObject(); for (IndexTemplateMetaData indexTemplateMetaData : getIndexTemplates()) { IndexTemplateMetaData.Builder.toXContent(indexTemplateMetaData, builder, params); } builder.endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { params = new ToXContent.DelegatingMapParams(singletonMap("reduce_mappings", "true"), params); builder.startObject(); for (IndexTemplateMetaData indexTemplateMetaData : getIndexTemplates()) { IndexTemplateMetaData.Builder.toXContent(indexTemplateMetaData, builder, params); } builder.endObject(); return builder; } }
@Override public RestResponse buildResponse(BulkByScrollResponse response, XContentBuilder builder) throws Exception { builder.startObject(); response.toXContent(builder, new ToXContent.DelegatingMapParams(params, channel.request())); builder.endObject(); return new BytesRestResponse(getStatus(response), builder); }
private static XContentBuilder build(RestChannel channel, RestStatus status, Exception e) throws IOException { ToXContent.Params params = channel.request(); if (params.paramAsBoolean("error_trace", !REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT)) { params = new ToXContent.DelegatingMapParams(singletonMap(REST_EXCEPTION_SKIP_STACK_TRACE, "false"), params); } else if (e != null) { Supplier<?> messageSupplier = () -> new ParameterizedMessage("path: {}, params: {}", channel.request().rawPath(), channel.request().params()); if (status.getStatus() < 500) { SUPPRESSED_ERROR_LOGGER.debug(messageSupplier, e); } else { SUPPRESSED_ERROR_LOGGER.warn(messageSupplier, e); } } XContentBuilder builder = channel.newErrorBuilder().startObject(); ElasticsearchException.generateFailureXContent(builder, params, e, channel.detailedErrorsEnabled()); builder.field(STATUS, status.getStatus()); builder.endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { params = new ToXContent.DelegatingMapParams(singletonMap("reduce_mappings", "true"), params); builder.startObject(); for (IndexTemplateMetaData indexTemplateMetaData : getIndexTemplates()) { IndexTemplateMetaData.Builder.toXContent(indexTemplateMetaData, builder, params); } builder.endObject(); return builder; }