cancel
Showing results for 
Search instead for 
Did you mean: 

Flow control and raising errors

maudrid
Champ on-the-rise
Champ on-the-rise
Good day.

I'd like to know the best practice in setting up the following workflow.

I have a process with a start form.
After the user submits the form and the process starts, I want to be able to check the input values and depending on some logic, raise an error so that the process does not start or is cancelled.
Is it better to use an execution listener with some find of script that can define a variable that I can then check in an exclusive gateway?
After that if there was an error I thought about using an End Error Event or End Terminate event.

I need to so something similar when a user task form is submitted.

Open to any other suggestions.

I'm using Activiti 6 Beta 2.
5 REPLIES 5

maudrid
Champ on-the-rise
Champ on-the-rise
Also, how do I throw a BpmnError from a script task using javascript?
I tried this:
var BpmnError = Java.type(org.activiti.engine.delegate.BpmnError');
throw new BpmnError("BusinessExeptionOccured","a Message");
But it has no effect.

maudrid
Champ on-the-rise
Champ on-the-rise
I got this working:
var BpmnError = Java.type('org.activiti.engine.delegate.BpmnError');
throw new BpmnError("BusinessExeptionOccured","a Message");
There was a missing quote.
Is this the best practice though? How should the error be handled?
Right now I get
<code>HTTP Status 500 - Request processing failed; nested exception is org.activiti.engine.delegate.BpmnError: No catching boundary event found for error with errorCode 'BusinessExeptionOccured', neither in same process nor in parent process.</code>

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

The error was thrown, but there is no catching event which could catch this error. That's the reason why engine is not able to continue in the process execution.

Regards
Martin

I understand.
In fact I do not want to continue execution. I'm using the REST API and I do want to show an error message to the user trying to complete the task. Trying to show a user friendly error message is hard when you have to rely on error 500.

That is why I would like to know what is the best practice when using the REST API.
If there is some error validating the user input, how do I let them know?

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

I would just throw Runtime exception and Rest endpoint should transform the exception into the meaningful message. (If it is not supported in the REST api - create a pull request)

Regards
Martin