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


Java RestStatus.INTERNAL_SERVER_ERROR屬性代碼示例

本文整理匯總了Java中org.elasticsearch.rest.RestStatus.INTERNAL_SERVER_ERROR屬性的典型用法代碼示例。如果您正苦於以下問題:Java RestStatus.INTERNAL_SERVER_ERROR屬性的具體用法?Java RestStatus.INTERNAL_SERVER_ERROR怎麽用?Java RestStatus.INTERNAL_SERVER_ERROR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.elasticsearch.rest.RestStatus的用法示例。


在下文中一共展示了RestStatus.INTERNAL_SERVER_ERROR屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: wrapExceptionToPreserveStatus

/**
 * Wrap the ResponseException in an exception that'll preserve its status code if possible so we can send it back to the user. We might
 * not have a constant for the status code so in that case we just use 500 instead. We also extract make sure to include the response
 * body in the message so the user can figure out *why* the remote Elasticsearch service threw the error back to us.
 */
static ElasticsearchStatusException wrapExceptionToPreserveStatus(int statusCode, @Nullable HttpEntity entity, Exception cause) {
    RestStatus status = RestStatus.fromCode(statusCode);
    String messagePrefix = "";
    if (status == null) {
        messagePrefix = "Couldn't extract status [" + statusCode + "]. ";
        status = RestStatus.INTERNAL_SERVER_ERROR;
    }
    try {
        return new ElasticsearchStatusException(messagePrefix + bodyMessage(entity), status, cause);
    } catch (IOException ioe) {
        ElasticsearchStatusException e = new ElasticsearchStatusException(messagePrefix + "Failed to extract body.", status, cause);
        e.addSuppressed(ioe);
        return e;
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:20,代碼來源:RemoteScrollableHitSource.java

示例2: status

/**
 * Returns the rest status code associated with this exception.
 */
public RestStatus status() {
    Throwable cause = unwrapCause();
    if (cause == this) {
        return RestStatus.INTERNAL_SERVER_ERROR;
    } else {
        return ExceptionsHelper.status(cause);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,代碼來源:ElasticsearchException.java

示例3: status

public static RestStatus status(Throwable t) {
    if (t != null) {
        if (t instanceof ElasticsearchException) {
            return ((ElasticsearchException) t).status();
        } else if (t instanceof IllegalArgumentException) {
            return RestStatus.BAD_REQUEST;
        }
    }
    return RestStatus.INTERNAL_SERVER_ERROR;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,代碼來源:ExceptionsHelper.java

示例4: status

/**
 * Returns snapshot REST status
 */
public RestStatus status() {
    if (state == SnapshotState.FAILED) {
        return RestStatus.INTERNAL_SERVER_ERROR;
    }
    if (shardFailures.size() == 0) {
        return RestStatus.OK;
    }
    return RestStatus.status(successfulShards, totalShards,
                             shardFailures.toArray(new ShardOperationFailedException[shardFailures.size()]));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:13,代碼來源:SnapshotInfo.java

示例5: status

/**
 * Returns snapshot REST status
 */
public RestStatus status() {
    if (state == SnapshotState.FAILED) {
        return RestStatus.INTERNAL_SERVER_ERROR;
    }
    if (shardFailures.size() == 0) {
        return RestStatus.OK;
    }
    return RestStatus.status(successfulShards, totalShards, shardFailures.toArray(new ShardOperationFailedException[shardFailures.size()]));
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:12,代碼來源:SnapshotInfo.java

示例6: status

@Override
public RestStatus status() {
    return RestStatus.INTERNAL_SERVER_ERROR;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:4,代碼來源:IndexPrimaryShardNotAllocatedException.java

示例7: ElasticsearchSecurityException

/**
 * Build the exception with a status of {@link RestStatus#INTERNAL_SERVER_ERROR} without a cause.
 */
public ElasticsearchSecurityException(String msg, Object... args) {
    this(msg, RestStatus.INTERNAL_SERVER_ERROR, args);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:6,代碼來源:ElasticsearchSecurityException.java

示例8: ShardSearchFailure

public ShardSearchFailure(String reason, SearchShardTarget shardTarget) {
    this(reason, shardTarget, RestStatus.INTERNAL_SERVER_ERROR);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:3,代碼來源:ShardSearchFailure.java

示例9: buildSQLActionException

/**
 * Create a {@link io.crate.action.sql.SQLActionException} out of a {@link java.lang.Throwable}.
 * If concrete {@link org.elasticsearch.ElasticsearchException} is found, first transform it
 * to a {@link io.crate.exceptions.CrateException}
 */
private SQLActionException buildSQLActionException(Throwable e) {
    logger.error("errors while processing sql", e);
    if (e instanceof SQLActionException) {
        return (SQLActionException) e;
    }
    e = esToCrateException(e);

    int errorCode = 5000;
    RestStatus restStatus = RestStatus.INTERNAL_SERVER_ERROR;
    if (e instanceof CrateException) {
        CrateException crateException = (CrateException) e;
        if (e instanceof ValidationException) {
            errorCode = 4000 + crateException.errorCode();
            restStatus = RestStatus.BAD_REQUEST;
        } else if (e instanceof NoPermissionException) {
            errorCode = 4000 + crateException.errorCode();
            restStatus = RestStatus.UNAUTHORIZED;
            e.setStackTrace(new StackTraceElement[0]);
        } else if (e instanceof ForbiddenException) {
            errorCode = 4030 + crateException.errorCode();
            restStatus = RestStatus.FORBIDDEN;
        } else if (e instanceof ResourceUnknownException) {
            errorCode = 4040 + crateException.errorCode();
            restStatus = RestStatus.NOT_FOUND;
        } else if (e instanceof ConflictException) {
            errorCode = 4090 + crateException.errorCode();
            restStatus = RestStatus.CONFLICT;
        } else if (e instanceof UnhandledServerException) {
            errorCode = 5000 + crateException.errorCode();
        }
    } else if (e instanceof ParsingException) {
        errorCode = 4000;
        restStatus = RestStatus.BAD_REQUEST;
    } else if (e instanceof MapperParsingException) {
        errorCode = 4000;
        restStatus = RestStatus.BAD_REQUEST;
    }

    String message = e.getMessage();
    if (message == null) {
        if (e instanceof CrateException && e.getCause() != null) {
            e = e.getCause();   // use cause because it contains a more meaningful error in most cases
        }
        StackTraceElement[] stackTraceElements = e.getStackTrace();
        if (stackTraceElements.length > 0) {
            message = String.format(Locale.ENGLISH, "%s in %s", e.getClass().getSimpleName(), stackTraceElements[0]);
        } else {
            message = "Error in " + e.getClass().getSimpleName();
        }
    } else {
        message = e.getClass().getSimpleName() + ": " + message;
    }
    return new SQLActionException(message, errorCode, restStatus, e.getStackTrace());
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:59,代碼來源:TransportBaseSQLAction.java

示例10: ElasticsearchSecurityException

public ElasticsearchSecurityException(String msg, Object... args) {
    this(msg, RestStatus.INTERNAL_SERVER_ERROR, null, args);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:3,代碼來源:ElasticsearchSecurityException.java

示例11: SnapshotShardFailure

/**
 * Constructs new snapshot shard failure object
 *
 * @param nodeId  node where failure occurred
 * @param shardId shard id
 * @param reason  failure reason
 */
public SnapshotShardFailure(@Nullable String nodeId, ShardId shardId, String reason) {
    this.nodeId = nodeId;
    this.shardId = shardId;
    this.reason = reason;
    status = RestStatus.INTERNAL_SERVER_ERROR;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:13,代碼來源:SnapshotShardFailure.java

示例12: SnapshotShardFailure

/**
 * Constructs new snapshot shard failure object
 *
 * @param nodeId  node where failure occurred
 * @param index   index which the shard belongs to
 * @param shardId shard id
 * @param reason  failure reason
 */
public SnapshotShardFailure(@Nullable String nodeId, String index, int shardId, String reason) {
    this.nodeId = nodeId;
    this.index = index;
    this.shardId = shardId;
    this.reason = reason;
    status = RestStatus.INTERNAL_SERVER_ERROR;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:15,代碼來源:SnapshotShardFailure.java


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