[loc-en-dev] Error handling in LocaleBuilder and forLanguageTag
Naoto.Sato at Sun.COM
Thu Mar 5 10:21:14 PST 2009
I have two comments as follows:
- Locale.forLanguageTag(): Please describe how the lenient behavior
works in the spec. This should not be implementation dependent.
- What happens with Builder.setLanguageTag(), if some other setXXX()s
are previously called and they conflict? Are they reset strictly to
setLanguageTag(), or superset tag is created, or an exception?
Yoshito Umaoka wrote:
> 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