Details
-
Type:
Story
-
Status: Accepted
-
Priority:
Must
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: Reference Application 2.3
-
Component/s: None
-
Labels:
-
Complexity:Low
-
Sprint:Sprint 2
-
Epic Link:
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" } ] } } }