Errors and validations in onFormSave event for form builder forms

we are introducing onFormSave events for the forms2 forms. This event should be written while creating a form in form builder. This event will be executed, after the form is filled and clicked on save in consultation page. We call this events as onFormSave event. Now, we are deciding up on, how we want to handle errors and validations in this scripts. this is the red banner, we also want to use to show the error.

  • All the syntactical errors will be anyhow handled and displayed as errors, in implementer interface, while writing the scripts itself.
  • For handling the errors, while executing the script - we can two different types.
  1. Handling validations, hence throwing the user defined exceptions in the script itself
  2. Handling run time exceptions thrown, if something is wrong/incorrect in script

For both the scenarios mentioned above, we are thinking to show the red banner, usually how errors were handled in bahmni. Please refer the screenshot for example.

For handling the errors, we want to give the two ways,

  1. Throw the exceptions, with throw key word
  2. Add all the error messages, to a array and return it to ui, and show them up.

Please comment, for any better solutions.

@snehabagri @sowmika @grssvinay @angshuonline @vmalini

Moved to the bahmni category.