diff options
author | Jeff Widman <jeff@jeffwidman.com> | 2017-12-07 12:58:28 -0800 |
---|---|---|
committer | Jeff Widman <jeff@jeffwidman.com> | 2017-12-07 13:04:11 -0800 |
commit | 3cc7e27807571913e526aa73bb56a2cca1ac67af (patch) | |
tree | 5563014f6ca1fea01781d52a9729169801cf24cc | |
parent | 5d1b13ef2812ddfe619495178f41e57b1fb640df (diff) | |
download | kafka-python-1274-producer-raise-non-api-exceptions.tar.gz |
Raise non-API exceptions1274-producer-raise-non-api-exceptions
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
-rw-r--r-- | kafka/producer/kafka.py | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/kafka/producer/kafka.py b/kafka/producer/kafka.py index 646e773..b1796b3 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)), |