Exception handling in scripts and listener events

I have a script task. Let’s assume I have a simple js code in the script task and it is in try and catch block (Exception handling). And I also have listeners events defined for the same script task. One of the listener task is a start event of type script. Even this script is under exception handling. And the other listener task is a end event of type script.

The concern is, if the code in my script task throws an error, it is handled by exception handling, but the task does not exit immediately. It goes on to execute the listener end script also. The same happens if the listener start code throws an error. It is handled by exception handling. But the task continues, first the code in script task gets executed and then end event is also executed.

This might be a problem if I am manipulating the same data in both start and end scripts. It does not make sense to execute end script if the start script hasn’t executed successfully. I want the task to exit as soon as a exception occurs.

Hello @Manjunath_HT ,

just remove the catch blocks, the engine will be able to deal with it.

Jonathan

1 Like