Pankraz76 commented on PR #2292:
URL: https://github.com/apache/maven/pull/2292#issuecomment-2861935795

   > This totally breaks the exception handling.
   
   I'm not sure—when asking AI and trying to mock it, both seem to say the same 
thing: "Checked exceptions must be declared!"
   That's how I remember Java's behavior ever since.
   
   <img width="814" alt="image" 
src="https://github.com/user-attachments/assets/32902eb0-b5fd-405c-b65e-5f3cbb5d3c1c";
 />
   
   <img width="907" alt="image" 
src="https://github.com/user-attachments/assets/0a5888a7-a762-4e9d-a123-847cc977db7e";
 />
   
   We shouldn't surprise the consumer by forcing them to handle a checked 
exception that hasn't been declared. A better experience would be to adapt the 
API to declare the exception properly, or remove the catch block if the 
exception can't occur by contract—especially since such cases aren't testable.
   
   > Currently, the API is designed to throw XmlReaderException. Check the 
implemented interface, there's no IOException thrown here.
   > 
   > >
   
   If no exception is thrown, then there's no need for a catch block—especially 
if it's not testable.
   
   ```
   org.mockito.exceptions.base.MockitoException: 
   Checked exception is invalid for this method!
   Invalid: java.io.IOException
   ```
   <img width="1801" alt="image" 
src="https://github.com/user-attachments/assets/12f1dac0-2ca6-4de9-95c6-6b7e18fe2e2a";
 />
   


-- 
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