當前位置: 首頁>>代碼示例>>Java>>正文


Java ExceptionsHelper.stackTrace方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:20,代碼來源:Strings.java

示例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]"));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:16,代碼來源:BytesRestResponseTests.java

示例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)) + "]";
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:5,代碼來源:ShardSearchFailure.java

示例4: toString

import org.elasticsearch.ExceptionsHelper; //導入方法依賴的package包/類
@Override
public String toString() {
    return "[" + index + "][" + shardId + "] failed, reason [" + reason() + "], cause [" + ExceptionsHelper.stackTrace(reason) + "]";
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:5,代碼來源:DefaultShardOperationFailedException.java


注:本文中的org.elasticsearch.ExceptionsHelper.stackTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。