BreakIterator out of bounds exception type fix

9 views
Skip to first unread message

Elango Cheran

unread,
May 22, 2025, 2:19:22 PMMay 22
to icu-d...@unicode.org
Hi everyone,
In working on the proposed Segmenter API, I've come across an inconsistency in the type of exceptions that BreakIterator throws.

In particular, when you call some APIs like `isBoundary(int offset)`, they will internally first check the provided offset value using a helper method `checkOffset(int offset, ...)`. In turn, checkOffset will throw an exception if the offset is out of range for the input string's indices. The inconsistency is that the exception it throws is IllegalArgumentException, when it should be IndexOutOfBoundsException.

I am planning to change the exception type from IllegalArgumentException to IndexOutOfBoundsException accordingly. Let me know if any of you take exception to that (pun sort of intended, sorry).

-- Elango

Elango Cheran

unread,
May 22, 2025, 2:25:11 PMMay 22
to icu-d...@unicode.org
Better yet, if you have comments, here's the ticket for discussion: https://unicode-org.atlassian.net/browse/ICU-23124

Markus Scherer

unread,
May 22, 2025, 2:34:59 PMMay 22
to Elango Cheran, icu-d...@unicode.org
+1 tnx
markus
Reply all
Reply to author
Forward
0 new messages