Marcono1234 commented on PR #1159: URL: https://github.com/apache/commons-lang/pull/1159#issuecomment-1891057775
> it should be done for (1) all call site of `String.format` For most other calls in Commons Lang the format string seems to be hardcoded (and therefore `IllegalFormatException` is most likely not possible), or at least it is on the 'happy path' where an incorrect format string would be more likely to be caught by users' unit tests, or where propagating the `IllegalFormatException` is the right thing to do because the malformed format string prevents correct functionality of the program. > This is dealing with a programming error IMO You are right with this. My concern here is that in most use cases `Validate` checks should pass successfully and no exception should be thrown, but if validation fails then it can be pretty important to see the validation message. However, if then instead an `IllegalFormatException` is thrown, it can make troubleshooting the validation failure pretty difficult. And the `IllegalFormatException` (which extends `IllegalArgumentException`) can also be an unexpected exception type for some of the `Validate` methods which are supposed to throw `IllegalStateException`, `IndexOutOfBoundsException` or `NullPointerException`. So even though this is definitely a programmer error, I think it is more important to preserve and show the original validation message in some form, than just propagating the `IllegalFormatException`. -- 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]
