summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Widman <jeff@jeffwidman.com>2017-12-21 14:48:15 -0800
committerDana Powers <dana.powers@gmail.com>2017-12-21 14:48:15 -0800
commitc49ae90b105fad958dbc60499aeedd27ff52416c (patch)
tree645709cf3930a330f1baec64679b24225e75d415
parentad024d1e897dbf16bd629fa63895bd7af4a8d959 (diff)
downloadkafka-python-c49ae90b105fad958dbc60499aeedd27ff52416c.tar.gz
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
-rw-r--r--kafka/producer/kafka.py6
1 files changed, 1 insertions, 5 deletions
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)),