diff --git a/src/Clients/Producer/KafkaProducer.php b/src/Clients/Producer/KafkaProducer.php index 679e733..64a5c5c 100644 --- a/src/Clients/Producer/KafkaProducer.php +++ b/src/Clients/Producer/KafkaProducer.php @@ -9,6 +9,7 @@ use RdKafka\ProducerTopic; use RuntimeException; +use function assert; use function sprintf; use const RD_KAFKA_PARTITION_UA; @@ -76,8 +77,10 @@ public function flushMessages(int $timeoutMs = 10000): void } } + assert($result !== null); + if ($result !== RD_KAFKA_RESP_ERR_NO_ERROR) { - throw new RuntimeException('Was unable to flush, messages might be lost!'); + throw new RuntimeException('Was unable to flush, messages might be lost!', $result); } } }