Details
-
New Feature
-
Status: Closed
-
Should
-
Resolution: Won't Fix
-
None
-
None
-
None
-
Low
Description
In a former issue (see linked issue) non-localized usage of APIException like these
throw new APIException("Location is required");
where error messages were hard-coded was replaced by using message keys.
Since the APIException(String) constructor does not treat the given string as a message key the constructor which also expects a parameter object was used. Leading to code like this
throw new APIException("Location.name.required", (Object[]) null);
Looking at the merge commit there are 141 occurrences where there is actually no need to pass a parameter array to the localized message but due to the behavior of the APIException(String) there is no other way around this.
SOLUTION:
change the APIException(String) implementation to
super(Context.getMessageSourceService().getMessage(message, null, message, Context.getLocale()));
this will lookup the message string in message properties and if not found default to the message string.
Like this it should not affect existing non-localized usage but enable cleaner use of localized messages without the need for parametrization.
Gliffy Diagrams
Attachments
Issue Links
- is related to
-
TRUNK-5180 MessageSourceService not found on startup in APIException
-
- Closed
-
- relates to
-
TRUNK-4500 Use of APIException not localized (mostly)
-
- Closed
-