paed01/bpmn-engine

Trigger Error from inside Task

Closed this issue · 3 comments

Hi,
is it possible to throw an error event from Task A(See Image below) inside an activity event listener so that task B is executed.

Bildschirmfoto 2021-09-03 um 13 40 24

listener.on('activity.start', (api) => {
    //Throw error event to go to task B 
    api.throwError();
}

I saw the script task example, but i need the error event in a normal task.
Thanks in advance.

I might have found a solution for you. Due to the synchronous nature of the engine you probably have to change your task A to a manual task. Otherwise there are some side effects since bpmn:task will execute immediately. Change the listener to this:

listener.on('activity.wait', (api) => {
  api.owner.emitFatal({id: 'SomeId', message: 'thrown in wait'}, {id: api.id});
}

Not so elegant but works.

@elmurd0r any luck?

Thank you very much, it works very well for me.