Uploaded image for project: 'Reference Application'
  1. Reference Application
  2. RA-903

Add a mechanism to display the errors returned from angular rest calls

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Approved
    • Priority: Must
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Reference Application 2.3
    • Component/s: None
    • Labels:

      Description

      Currently, when an app makes a rest call via an angular resource, it needs to figure out a way to handle failures and display error messages, we should provide a way do this globally for all rest calls.

      Dev Notes:

      Add emr.messages function to emr.js(uicommons module) which is a variation of emr.message(..) function that takes an array of messages, note that the error messages from our rest API already come with the translated message.

      Add a new angular module in a separate file that has an angular response interceptor which gets the error object from the response if any, creates an array of the messages(starting with global ones) and then delegates to your new emr.messages function in order to display the error messages as a toast message.

      Extra credit for updating existing apps for the manage metadata pages to include the new interceptor.

      Below is what the error object in a response would look like

      {
        "error": {
          "message": "Invalid Submission",
          "code": "webservices.rest.error.invalid.submission",
          "globalErrors": [
            {
              "code": "EncounterType.error.duplicateEncounterTypeNameSpecified",
              "message": "Encounter Type name already exists, please specify another"
            }
          ],
          "fieldErrors": {
            "name": [
              {
                "code": "EncounterType.error.duplicateEncounterTypeNameSpecified",
                "message": "Encounter Type name already exists, please specify another"
              }
            ]
          }
        }
      }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              Assignee:
              wyclif Wyclif Luyima
              Reporter:
              wyclif Wyclif Luyima
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: