Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-4500

Use of APIException not localized (mostly)

    XMLWordPrintable

    Details

      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

              Activity

                People

                Assignee:
                rpuzdrowski Radosław Puzdrowski
                Reporter:
                lluismf Lluis Martinez
                Votes:
                2 Vote for this issue
                Watchers:
                9 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 2 days, 5 hours
                    2d 5h