本文整理汇总了Java中org.elasticsearch.ExceptionsHelper.stackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java ExceptionsHelper.stackTrace方法的具体用法?Java ExceptionsHelper.stackTrace怎么用?Java ExceptionsHelper.stackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.ExceptionsHelper
的用法示例。
在下文中一共展示了ExceptionsHelper.stackTrace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
/**
* Return a {@link String} that is the json representation of the provided {@link ToXContent}.
* Wraps the output into an anonymous object.
*/
public static String toString(ToXContent toXContent) {
try {
XContentBuilder builder = JsonXContent.contentBuilder();
if (toXContent.isFragment()) {
builder.startObject();
}
toXContent.toXContent(builder, ToXContent.EMPTY_PARAMS);
if (toXContent.isFragment()) {
builder.endObject();
}
return builder.string();
} catch (IOException e) {
return "Error building toString out of XContent: " + ExceptionsHelper.stackTrace(e);
}
}
示例2: testConvert
import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
public void testConvert() throws IOException {
RestRequest request = new FakeRestRequest();
RestChannel channel = new DetailedExceptionRestChannel(request);
ShardSearchFailure failure = new ShardSearchFailure(new ParsingException(1, 2, "foobar", null),
new SearchShardTarget("node_1", new Index("foo", "_na_"), 1));
ShardSearchFailure failure1 = new ShardSearchFailure(new ParsingException(1, 2, "foobar", null),
new SearchShardTarget("node_1", new Index("foo", "_na_"), 2));
SearchPhaseExecutionException ex = new SearchPhaseExecutionException("search", "all shards failed", new ShardSearchFailure[] {failure, failure1});
BytesRestResponse response = new BytesRestResponse(channel, new RemoteTransportException("foo", ex));
String text = response.content().utf8ToString();
String expected = "{\"error\":{\"root_cause\":[{\"type\":\"parsing_exception\",\"reason\":\"foobar\",\"line\":1,\"col\":2}],\"type\":\"search_phase_execution_exception\",\"reason\":\"all shards failed\",\"phase\":\"search\",\"grouped\":true,\"failed_shards\":[{\"shard\":1,\"index\":\"foo\",\"node\":\"node_1\",\"reason\":{\"type\":\"parsing_exception\",\"reason\":\"foobar\",\"line\":1,\"col\":2}}]},\"status\":400}";
assertEquals(expected.trim(), text.trim());
String stackTrace = ExceptionsHelper.stackTrace(ex);
assertTrue(stackTrace.contains("Caused by: ParsingException[foobar]"));
}
示例3: toString
import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
@Override
public String toString() {
return "shard [" + (shardTarget == null ? "_na" : shardTarget) + "], reason [" + reason + "], cause [" + (cause == null ? "_na" : ExceptionsHelper.stackTrace(cause)) + "]";
}
示例4: toString
import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
@Override
public String toString() {
return "[" + index + "][" + shardId + "] failed, reason [" + reason() + "], cause [" + ExceptionsHelper.stackTrace(reason) + "]";
}