cancel
Showing results for 
Search instead for 
Did you mean: 

ErrorEndEvent is not propagated to parent process

joao_p_silva
Champ in-the-making
Champ in-the-making
We have two processes, A and B, where B is a sub-process of A.

In the parent process A, we have an Event Sub-Process with an ErrorStartEvent with Error Code "customError".

In process B, we also have an Event Sub-Process with an ErrorStartEvent with Error Code "customError", but at the end, we re-throw this same error code with an ErrorEndEvent, in order to trigger the Event Sub-Process of the parent process A.

This, however, produces an infinite loop. In other words, instead of propagating the ErrorEndEvent from process B to the parent process A, it keeps processing the error in process B. Making an analogy with Java, what we have is the following:


A() { // Parent Process
  try {
    B();  // Sub Process
  } catch (CustomError e) {  // Event Sub Process ErrorStartEvent
    doSomething();
  }
}

B() {
  try {
    doSomethingElse();
  } catch (CustomError e) { // Event Sub Process ErrorStartEvent
    doYetSomething();
    throw e; // This ErrorEndEvent is never caught by A
  }
}


However, the Exception from B never reaches A, it keeps looping in the catch block of B.
4 REPLIES 4

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

As I  understand error is caught in subprocess B in the event sub-subprocess.

I can  be sure only when I write jUnit test, but what could happen is following:


  public static void propagateError(String errorCode, ActivityExecution execution) throws Exception {
    // find local error handler
    String eventHandlerId = findLocalErrorEventHandler(execution, errorCode); 

    // TODO: merge two approaches (super process / regular process approach)
    if(eventHandlerId != null) {
      executeCatch(eventHandlerId, execution);
    }else {
      ActivityExecution superExecution = getSuperExecution(execution);
      if (superExecution != null) {
        executeCatchInSuperProcess(errorCode, superExecution);
      } else {
        LOG.info("{} throws error event with errorCode '{}', but no catching boundary event was defined. Execution will simply be ended (none end event semantics).",
                execution.getActivity().getId(), errorCode);
        execution.end();
      }
    }
  }

org.activiti.engine.impl.bpmn.helper.ErrorPropagation#findLocalErrorEventHandler finds current event subprocess and that's why it ends in endless loop. Your case can be solved by changing error code.

The question is whether it is correct behavior or not.

Regards
Martin

joao_p_silva
Champ in-the-making
Champ in-the-making
Hi Martin, thank you for your prompt feedback.

According to the documentation of an Error End Event:

When process execution arrives in an error end event, the current path of execution is ended and an error is thrown.

My interpretation of this sentence is that the current event subprocess is the current path of execution, and therefore, should be ended, with the error being thrown to the parent process (not back to itself). In other words, an end event should always end the current path of execution.

trademak
Star Contributor
Star Contributor
Hi,

When you mean sub process is it a separate process definition invoked with a call activity? Or is it part of the same process definition?
Could you create a unit test and a JIRA issue?

Best regards,

joao_p_silva
Champ in-the-making
Champ in-the-making
Hi,

Yes, indeed, it's a separate process invoked with a call activity. I've created the following JIRA: http://jira.codehaus.org/browse/ACT-1937, which contains a failing unit test of the issue. Please let me know if you need something else.

Best regards,
João