Camunda required to display error message and end the task

I need to end a task based on a boolean value.

  1. I am either able to end the task ( remove it from task list) if I thrown an error in doExecute() method but that does not display the error message to the users.
  2. If I handle the same in a formValidator class(ie…, a class which implements FormFieldValidator), I can display a proper error message on throwing FormException. But this leaves the task in the task list as it is.

I want both step1 and step 2 to happen, ie…, display an error message to the user and then remove the task from the task list.