コード例 #1
0
 protected final void renderHeader(XContentBuilder builder, Params params) throws IOException {
   boolean hasHeader = false;
   for (String key : headers.keySet()) {
     if (key.startsWith("es.")) {
       continue;
     }
     if (hasHeader == false) {
       builder.startObject("header");
       hasHeader = true;
     }
     List<String> values = headers.get(key);
     xContentHeader(builder, key, values);
   }
   if (hasHeader) {
     builder.endObject();
   }
 }
コード例 #2
0
 @Override
 public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
   Throwable ex = ExceptionsHelper.unwrapCause(this);
   if (ex != this) {
     toXContent(builder, params, this);
   } else {
     builder.field("type", getExceptionName());
     builder.field("reason", getMessage());
     for (String key : headers.keySet()) {
       if (key.startsWith("es.")) {
         List<String> values = headers.get(key);
         xContentHeader(builder, key.substring("es.".length()), values);
       }
     }
     innerToXContent(builder, params);
     renderHeader(builder, params);
     if (params.paramAsBoolean(
             REST_EXCEPTION_SKIP_STACK_TRACE, REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT)
         == false) {
       builder.field("stack_trace", ExceptionsHelper.stackTrace(this));
     }
   }
   return builder;
 }