From c49ae90b105fad958dbc60499aeedd27ff52416c Mon Sep 17 00:00:00 2001 From: Jeff Widman Date: Thu, 21 Dec 2017 14:48:15 -0800 Subject: Raise non-API exceptions (#1316) The original intent was to catch API exceptions (errors returned by the broker when trying to produce a message) and delegate them to the messages' futures. This is copied from the Java producer. However, we were accidentally catching all exceptions, thereby hiding exceptions from users unless they explicitly check the result of the future. Much better to raise client-side errors directly in the foreground so the user is immediately aware of them and can decide how to handle. Fix #1274 --- kafka/producer/kafka.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'kafka') diff --git a/kafka/producer/kafka.py b/kafka/producer/kafka.py index 5d32b13..e0c8a41 100644 --- a/kafka/producer/kafka.py +++ b/kafka/producer/kafka.py @@ -571,11 +571,7 @@ class KafkaProducer(object): # handling exceptions and record the errors; # for API exceptions return them in the future, # for other exceptions raise directly - except Errors.KafkaTimeoutError: - raise - except AssertionError: - raise - except Exception as e: + except Errors.BrokerResponseError as e: log.debug("Exception occurred during message send: %s", e) return FutureRecordMetadata( FutureProduceResult(TopicPartition(topic, partition)), -- cgit v1.2.1