cancel
Showing results for 
Search instead for 
Did you mean: 

How to get access to source BpmnError in error start event subprocess?

lehvolk
Champ in-the-making
Champ in-the-making
Hi,
I have a process whick called many times in a loop. If during execution some error occured I want to add a message into report. I try to make sub-process with error start event such this:


<subProcess id="error-handling" name="error-handling" triggeredByEvent="true">
   <startEvent id="start-error-event" name="start error event">
      <errorEventDefinition />
   </startEvent>
   <serviceTask id="add-error" name="add error to report"  activiti:expression="${reports.addError(….)}"></serviceTask>
….
</subProcess>


But inside of this sub-process I couldn't find any way to access the source exception (BpmnError or other). Does anybody know any standard way to do this or any workaround?
6 REPLIES 6

lehvolk
Champ in-the-making
Champ in-the-making
Still no ideas? It seems that it is common case like in try-catch, when you have access to caught exception.

trademak
Star Contributor
Star Contributor
That's not how the BpmnError is meant to be used. You should look at it as a logical error with a simple id or errorRef property only. So it's not meant to pass along technical exceptions. If you want to do that it's best to use a process variable.

Best regards,

lehvolk
Champ in-the-making
Champ in-the-making
Thanks for answer. I check source code and find class ErrorPropagation which implement logic for error handling. As I see not BpmnError and error code not set into the execution. So in my case (where I want to handle BpmnError's with all codes) I also can't get error code. Is this true? 

Can you tell me Is it safe to correct activiti engine ErrorPropagation by this code:
<code>
  public static void propagateError(BpmnError error, ActivityExecution execution) throws Exception {   
      execution.setVariableLocal("__errorCodeAlias", error.getErrorCode());
      propagateError(error.getErrorCode(), execution);
  }
</code>

trademak
Star Contributor
Star Contributor
What do you mean with "I also can't get error code" ? From where?
If you want to change the Activiti core logic that's of course up to you, but upgrading to a new version might be more difficult then.

Best regards,

lehvolk
Champ in-the-making
Champ in-the-making
As I understand there is no access to errorCode inside this sub-process which handles all kind of business errors. In curent activiti version the only way to separate logic between them is to define two sub-processes with error start events for different error codes.

Thanks a lot for answers.

trademak
Star Contributor
Star Contributor
Yes, that's correct. Two separate event sub processes would work. But it would be an improvement if you could also do this in the same event sub process. Could you raise a JIRA for this?

Thanks,