public void onSendError(ProducerRecord<K, V> record, TopicPartition interceptTopicPartition, Exception exception) {
        for (ProducerInterceptor<K, V> interceptor : this.interceptors) {
            try {
                if (record == null && interceptTopicPartition == null) {
                    interceptor.onAcknowledgement(null, exception);
                } else {
                    if (interceptTopicPartition == null) {
                        interceptTopicPartition = extractTopicPartition(record);
                    }
                    interceptor.onAcknowledgement(new RecordMetadata(interceptTopicPartition, -1, -1,
                                    RecordBatch.NO_TIMESTAMP, -1, -1), exception);
                }
            } catch (Exception e) {
                // do not propagate interceptor exceptions, just log
                log.warn("Error executing interceptor onAcknowledgement callback", e);
            }
        }
    }
This method is called when sending the record fails in {@link ProducerInterceptor#onSend
(ProducerRecord)} method. This method calls {@link ProducerInterceptor#onAcknowledgement(RecordMetadata, Exception)}
method for each interceptor

@param record The record from client
@param interceptTopicPartition  The topic/partition for the record if an error occurred
       after partition gets assigned; the topic part of interceptTopicPartition is the same as in record.
@param exception The exception thrown during processing of this record.
clients/src/main/java/org/apache/kafka/clients/producer/internals/ProducerInterceptors.java