public boolean completeExceptionally(
        RuntimeException topLevelException,
        Function<Integer, RuntimeException> recordExceptions
    ) {
        Objects.requireNonNull(topLevelException);
        Objects.requireNonNull(recordExceptions);
        return done(ProduceResponse.INVALID_OFFSET, RecordBatch.NO_TIMESTAMP, topLevelException, recordExceptions);
    }
Complete the batch exceptionally. The provided top-level exception will be used
for each record future contained in the batch.

@param topLevelException top-level partition error
@param recordExceptions Record exception function mapping batchIndex to the respective record exception
@return true if the batch was completed as a result of this call, and false
  if it had been completed previously
clients/src/main/java/org/apache/kafka/clients/producer/internals/ProducerBatch.java