Change the full error message of a thrown RuntimeException

Hi at all,
I implemented in my BPMN the four-eyes principle. There are two tasks and both tasks cannot be done by the same person. When you click the claim button of the second task, a Listener is called and the Listener checks if the same person allready completed the first task. If this is the case, the Listener throws a RuntimeException with a message:

throw new RuntimeException(“Same user has already completed the first task, cannot complete second task, violates 4-eyes-principle”);

The error message looks like this:

However I want to shorten the displayed error message. Currently it says “ENGINE-03501 There was an exception while …”, but I want it to display ONLY my message “Same user has already completed …”.

Is there any way to do this?
Thanks for your help.
Kind regards,
Marvin

Hi @MarvinKern,

Try below code in your embedded html form.

camForm.on('submit-failed', function (evt, res) {
	var errMsg;
	
	// replace below line of code with your custom error message
	// based on the retrieved value of res[0]
	errMsg = res[0];
	
	
	$timeout(function() {
		Notifications.clearAll();
		
		Notifications.addError({
		  status: 'ERROR',
		  message: errMsg,
		  scope: $scope
		})
	});
});

Hi hassang,
Sorry I described the case wrong. I will correct the description:
I want the error message to appear, when the user is clicking claim on the second task.
But the error message will appear, because the user is not allowed to claim the second task, when he already finished the first task.

Hi @MarvinKern,

I don’t think that is possible…

" submit-failed , error-failed or escalation-failed is fired after the server failed at treating the submission or when a network error happened."

https://docs.camunda.org/manual/latest/reference/embedded-forms/lifecycle/

Hi hassang,
Allright, thank you very much for your help :slight_smile: