Search in sources :

Example 6 with BadValueException

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);
    }
}
Also used : BadValueException(com.eightkdata.mongowp.exceptions.BadValueException) MongoException(com.eightkdata.mongowp.exceptions.MongoException) UnknownErrorException(com.eightkdata.mongowp.exceptions.UnknownErrorException) ErrorCode(com.eightkdata.mongowp.ErrorCode)

Aggregations

BadValueException (com.eightkdata.mongowp.exceptions.BadValueException)6 BsonDocument (com.eightkdata.mongowp.bson.BsonDocument)5 NoSuchKeyException (com.eightkdata.mongowp.exceptions.NoSuchKeyException)4 TypesMismatchException (com.eightkdata.mongowp.exceptions.TypesMismatchException)4 ErrorCode (com.eightkdata.mongowp.ErrorCode)1 OpTime (com.eightkdata.mongowp.OpTime)1 BsonArray (com.eightkdata.mongowp.bson.BsonArray)1 BsonType (com.eightkdata.mongowp.bson.BsonType)1 BsonValue (com.eightkdata.mongowp.bson.BsonValue)1 MongoConnection (com.eightkdata.mongowp.client.core.MongoConnection)1 MongoException (com.eightkdata.mongowp.exceptions.MongoException)1 OplogOperationUnsupported (com.eightkdata.mongowp.exceptions.OplogOperationUnsupported)1 OplogStartMissingException (com.eightkdata.mongowp.exceptions.OplogStartMissingException)1 UnknownErrorException (com.eightkdata.mongowp.exceptions.UnknownErrorException)1 QueryOption (com.eightkdata.mongowp.messages.request.QueryMessage.QueryOption)1 QueryOptions (com.eightkdata.mongowp.messages.request.QueryMessage.QueryOptions)1 DbCmdOplogOperation (com.eightkdata.mongowp.server.api.oplog.DbCmdOplogOperation)1 DbOplogOperation (com.eightkdata.mongowp.server.api.oplog.DbOplogOperation)1 DeleteOplogOperation (com.eightkdata.mongowp.server.api.oplog.DeleteOplogOperation)1 InsertOplogOperation (com.eightkdata.mongowp.server.api.oplog.InsertOplogOperation)1