Пример #1
0
    BatchedErrorDetail* BatchSafeWriter::lastErrorToBatchError( const LastError& lastError ) {

        if ( BatchSafeWriter::isFailedOp( lastError ) ) {
            BatchedErrorDetail* batchError = new BatchedErrorDetail;
            if ( lastError.code != 0 ) batchError->setErrCode( lastError.code );
            else batchError->setErrCode( ErrorCodes::UnknownError );
            batchError->setErrMessage( lastError.msg );
            return batchError;
        }

        return NULL;
    }
Пример #2
0
    BatchedErrorDetail* BatchSafeWriter::lastErrorToBatchError( const LastError& lastError ) {

        bool isFailedOp = lastError.msg != "";
        bool isStaleOp = lastError.writebackId.isSet();
        dassert( !( isFailedOp && isStaleOp ) );

        if ( isFailedOp ) {
            BatchedErrorDetail* batchError = new BatchedErrorDetail;
            if ( lastError.code != 0 ) batchError->setErrCode( lastError.code );
            else batchError->setErrCode( ErrorCodes::UnknownError );
            batchError->setErrMessage( lastError.msg );
            return batchError;
        }
        else if ( isStaleOp ) {
            BatchedErrorDetail* batchError = new BatchedErrorDetail;
            batchError->setErrCode( ErrorCodes::StaleShardVersion );
            batchError->setErrInfo( BSON( "downconvert" << true ) ); // For debugging
            batchError->setErrMessage( "shard version was stale" );
            return batchError;
        }

        return NULL;
    }