Details
-
Bug
-
Status: Closed
-
Should
-
Resolution: Fixed
-
None
-
None
Description
Most of APIException usages (about 261) show a hardcoded english message instead of reading the corresponding localized resource.
Wrong:
throw new APIException("Preferred name cannot be null, voided or an index term");
Right:
throw new APIException(Context.getMessageSourceService().getMessage("Cohort.save.nameRequired", null,
"Cohort name is required", Context.getLocale()));
Proposal: add a new constructor to APIException with 2 arguments: message key and array of parameters. In its body call the Context.getMessageSourceService. Store both arguments as members (as long as the message), in order to allow unit tests to check for the resource key. I don't think it's necessary to provide a default message, if the resource does not exist in the context locale find it in english.
Unit tests checking for english messages should be reviewed too. See OrderServiceTest for examples.
Gliffy Diagrams
Attachments
Issue Links
- is related to
-
TRUNK-5124 Make APIException(String) behave localized
-
- Closed
-