本文整理匯總了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) + "]";
}