Java Code Examples for org.elasticsearch.ExceptionsHelper#detailedMessage()

The following examples show how to use org.elasticsearch.ExceptionsHelper#detailedMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MoreLikeThisQueryBuilder.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public final String toString() {
    try {
        XContentBuilder builder = XContentFactory.jsonBuilder();
        builder.prettyPrint();
        toXContent(builder, EMPTY_PARAMS);
        return builder.string();
    } catch (Exception e) {
        return "{ \"error\" : \"" + ExceptionsHelper.detailedMessage(e) + "\"}";
    }
}
 
Example 2
Source File: UnassignedInfo.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a string representation of the message and the failure if exists.
 */
@Nullable
public String getDetails() {
    if (message == null) {
        return null;
    }
    return message + (failure == null ? "" : ", failure " + ExceptionsHelper.detailedMessage(failure));
}
 
Example 3
Source File: CountRequestBuilder.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    if (sourceBuilder != null) {
        return sourceBuilder.toString();
    }
    if (request.source() != null) {
        try {
            return XContentHelper.convertToJson(request.source().toBytesArray(), false, true);
        } catch (Exception e) {
            return "{ \"error\" : \"" + ExceptionsHelper.detailedMessage(e) + "\"}";
        }
    }
    return new QuerySourceBuilder().toString();
}
 
Example 4
Source File: ShardSearchFailure.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public ShardSearchFailure(Throwable t, @Nullable SearchShardTarget shardTarget) {
    Throwable actual = ExceptionsHelper.unwrapCause(t);
    if (actual != null && actual instanceof SearchException) {
        this.shardTarget = ((SearchException) actual).shard();
    } else if (shardTarget != null) {
        this.shardTarget = shardTarget;
    }
    status = ExceptionsHelper.status(actual);
    this.reason = ExceptionsHelper.detailedMessage(t);
    this.cause = actual;
}
 
Example 5
Source File: SearchRequestBuilder.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    if (sourceBuilder != null) {
        return sourceBuilder.toString();
    }
    if (request.source() != null) {
        try {
            return XContentHelper.convertToJson(request.source().toBytesArray(), false, true);
        } catch (Exception e) {
            return "{ \"error\" : \"" + ExceptionsHelper.detailedMessage(e) + "\"}";
        }
    }
    return new SearchSourceBuilder().toString();
}
 
Example 6
Source File: ToXContentToBytes.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public final String toString() {
    try {
        XContentBuilder builder = XContentFactory.jsonBuilder();
        builder.prettyPrint();
        toXContent(builder, EMPTY_PARAMS);
        return builder.string();
    } catch (Exception e) {
        return "{ \"error\" : \"" + ExceptionsHelper.detailedMessage(e) + "\"}";
    }
}
 
Example 7
Source File: UnassignedInfo.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a string representation of the message and the failure if exists.
 */
@Nullable
public String getDetails() {
    if (message == null) {
        return null;
    }
    return message + (failure == null ? "" : ", failure " + ExceptionsHelper.detailedMessage(failure));
}
 
Example 8
Source File: ReplicationResponse.java    From crate with Apache License 2.0 5 votes vote down vote up
public Failure(ShardId shardId,
               @Nullable String nodeId,
               Exception cause,
               RestStatus status,
               boolean primary) {
    super(shardId.getIndexName(), shardId.getId(), ExceptionsHelper.detailedMessage(cause), status, cause);
    this.shardId = shardId;
    this.nodeId = nodeId;
    this.primary = primary;
}
 
Example 9
Source File: FailedRerouteAllocation.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return "node[" + finderNodeId + "] find afailed shard, shard " + shard + ", message [" + message + "], failure [" + ExceptionsHelper.detailedMessage(failure) + "]";
}
 
Example 10
Source File: ActionWriteResponse.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * @return A text description of the failure
 */
@Override
public String reason() {
    return ExceptionsHelper.detailedMessage(cause);
}
 
Example 11
Source File: FailedShard.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return "failed shard, shard " + routingEntry + ", message [" + message + "], failure [" +
               ExceptionsHelper.detailedMessage(failure) + "], markAsStale [" + markAsStale + "]";
}