[loc-en-dev] Error handling in LocaleBuilder and forLanguageTag
y.umaoka at gmail.com
Tue Mar 3 19:07:40 PST 2009
We discussed about error handling behavior in the locale builder and the
factory method Locale#forLanguageTag in the project conference call
today. Doug summarized the current consensus below -
- throw a runtime exception (for well managed inputs, caller does not
require try-catch) on setters if ill-formed (including setLocale with a
locale that has no canonical BCP47 form)
- remove createStrict()
- add setLanguageTag (and throw a runtime exception if ill-formed)
- throw null pointer exception for all null arguments. setXXX is still
used for clear the target internal field, but must use empty string ""
for the purpose.
- throw null pointer exception for null argument
- continue supporting lenient behavior (no exception throw)
I think we probably do not need a dedicated class for the exception -
probably just use IllegalArgumentException for Builder#setXXX. (It
might be too ambiguous for setLanguageTag, but for other cases, syntax
check should be pretty simple, so call should be able to figure out the
error before hand)
If anyone has any alternative proposal, please respond to this message.
More information about the locale-enhancement-dev