Thanks Matthias, I think your proposal makes sense as well, on the pro side we could have a universally agreed exception type to be caught by the user, without having an extra layer on top of the actual exceptions. I could see some issue on downsides:
1. The exception hierarchy will be more complex. Right now we have RetriableException type, if we are going to add a `ProducerRetriableException` type, we have to put this new interface as the parent of the RetriableException, because not all thrown non-fatal exceptions are `retriable` in general for producer, for example <https://github.com/apache/kafka/blob/e275742f850af4a1b79b0d1bd1ac9a1d2e89c64e/clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java#L745>. We could have an empty interface `ProducerRetriableException` to let all the thrown exceptions implement for sure, but it's a bit unorthodox in the way we deal with exceptions in general. 2. There are cases where we throw a KafkaException wrapping another KafkaException as either fatal or non-fatal. If we use an interface to solve #1, it is also required to implement another bloated exception class which could replace KafkaException type, as we couldn't mark KafkaException as retriable for sure. 3. In terms of the encapsulation, wrapping means we could limit the scope of affection to the producer only, which is important since we don't want shared exception types to implement a producer-related interface, such as UnknownTopicOrPartitionException. Best, Boyang On Wed, Dec 2, 2020 at 3:38 PM Matthias J. Sax <mj...@apache.org> wrote: > Thanks for the KIP Boyang! > > Overall, categorizing exceptions makes a lot of sense. As I don't know > the producer internals well enough, I cannot comment on the > categorization in detail though. > > What I am wondering is, if we should introduce an exception interface > that non-fatal exception would implement instead of creating a new class > that will wrap non-fatal exceptions? What would be the pros/cons for > both designs? > > > -Matthias > > > On 12/2/20 11:35 AM, Boyang Chen wrote: > > Hey there, > > > > I would like to start a discussion thread for KIP-691: > > > https://cwiki.apache.org/confluence/display/KAFKA/KIP-691%3A+Enhance+Transactional+Producer+Exception+Handling > > > > The KIP is aiming to simplify the exception handling logic for > > transactional Producer users by classifying fatal and non-fatal > exceptions > > and throw them correspondingly for easier catch and retry. Let me know > what > > you think. > > > > Best, > > Boyang > > >