private void checkExceptions() throws IOException {
    if (sendExceptionRef.get() != null && sendExceptionRef.get() instanceof KafkaException && sendExceptionRef.get()
        .getCause() instanceof ProducerFencedException) {
      // producer.send() may throw a KafkaException which wraps a FencedException re throw its wrapped inner cause.
      sendExceptionRef.updateAndGet(e -> (KafkaException) e.getCause());
    }
    if (sendExceptionRef.get() != null) {
      final Exception exception = sendExceptionRef.get();
      logHints(exception);
      if (tryToAbortTx(exception)) {
        LOG.error("Aborting Transaction [{}] cause by ERROR [{}]", writerIdTopicId, exception.getMessage());
        producer.abortTransaction();
      }
      LOG.error("Closing writer [{}] caused by ERROR [{}]", writerIdTopicId, exception.getMessage());
      producer.close(DURATION_0);
      throw new IOException(exception);
    }
  }
Checks for existing exception. In case of exception will close consumer and rethrow as IOException
@throws IOException abort if possible, close consumer then rethrow exception.
kafka-handler/src/java/org/apache/hadoop/hive/kafka/TransactionalKafkaWriter.java