RFR: 8353713: Improve Currency.getInstance exception handling
Naoto Sato
naoto at openjdk.org
Fri Apr 4 22:54:53 UTC 2025
On Fri, 4 Apr 2025 21:25:00 GMT, Justin Lu <jlu at openjdk.org> wrote:
> Please review this PR which improves some Currency `IllegalArgumentException`s by including the input in the message. This could be a currency code, country code, or locale. This change also includes tests to check the messages for an invalid country via the region override as well as an invalid country code within a 3 length currency code.
Looks good.
test/jdk/java/util/Currency/CurrencyTest.java line 102:
> 100: IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () ->
> 101: Currency.getInstance(badCode), "getInstance() did not throw IAE");
> 102: assertEquals("The country code: \"%s\" is not a valid ISO 3166 code"
Since the test is not parameterized, we can simply use ".." inside the expected string literal.
-------------
PR Review: https://git.openjdk.org/jdk/pull/24459#pullrequestreview-2744244252
PR Review Comment: https://git.openjdk.org/jdk/pull/24459#discussion_r2029528590
More information about the core-libs-dev
mailing list