use of com.eightkdata.mongowp.exceptions.BadValueException in project torodb by torodb.
the class ReplSetHeartbeatReplyMarshaller method checkCommandError.
private static void checkCommandError(BsonDocument bson, String setName) throws MongoException {
if (setName == null && !BsonReaderTool.isPseudoTrue(bson, OK_FIELD)) {
String errMsg = BsonReaderTool.getString(bson, ERR_MSG_FIELD, "");
assert errMsg != null;
Entry<?> errorCodeEntry = BsonReaderTool.getEntry(bson, ERROR_CODE_FIELD, null);
if (errorCodeEntry != null) {
if (!errorCodeEntry.getValue().isNumber()) {
throw new BadValueException(ERROR_CODE_FIELD + " is " + "not a number");
}
ErrorCode errorCode = ErrorCode.fromErrorCode(errorCodeEntry.getValue().asNumber().intValue());
throw new MongoException(errMsg, errorCode);
}
throw new UnknownErrorException(errMsg);
}
}
Aggregations