chickenchickenlove commented on PR #20159:
URL: https://github.com/apache/kafka/pull/20159#issuecomment-3477283325

   @chia7712 , thanks for your comments. 
   
   > Are there situations where using a custom exception is necessary for 
clearer error reporting?
   
   ```java
       // 
https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java#L1224
       private ClusterAndWaitTime waitOnMetadata(String topic, Integer 
partition, long nowMs, long maxWaitMs) throws InterruptedException {
              ...
               try {
                   metadata.awaitUpdate(version, remainingWaitMs); // <----
               } 
              ...
   ```
   Here, a `TimeoutException` is thrown by `SystemTime`.
   However, when a `TimeoutException` occurs, it’s not possible to know the 
specific cause of the error.
   Therefore, by providing an expected error through a `Supplier`, we can 
obtain more contextual information about the likely cause when a 
`TimeoutException` is thrown at runtime.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to