本文整理汇总了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;
}
}
示例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);
}
}
示例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;
}
示例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()]));
}
示例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()]));
}
示例6: status
@Override
public RestStatus status() {
return RestStatus.INTERNAL_SERVER_ERROR;
}
示例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);
}
示例8: ShardSearchFailure
public ShardSearchFailure(String reason, SearchShardTarget shardTarget) {
this(reason, shardTarget, RestStatus.INTERNAL_SERVER_ERROR);
}
示例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());
}
示例10: ElasticsearchSecurityException
public ElasticsearchSecurityException(String msg, Object... args) {
this(msg, RestStatus.INTERNAL_SERVER_ERROR, null, args);
}
示例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;
}
示例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;
}