Variables of error catch event

Hello all

in the documentation of Camunda 8.2 under Modeler/BPMN/Events/Error events there is the following description:

Variable mappings
All error variables are merged into the error catch event. These variables can be merged into the process instance by defining an output mapping at the error catch event.

But I can’t find a suitable variable for the source. There always comes the error message:
failed to evaluate expression ‘{ErrorMessage:message}’: no variable found for name ‘message’

Which variables are possible as Outputs Variable in element ERROR START EVENT in a EVENT SUB PROCESS?

      <bpmn:startEvent id="Event_0tlbhrz">
        <bpmn:extensionElements>
          <zeebe:ioMapping>
            <zeebe:output source="=message" target="ErrorMessage" />
          </zeebe:ioMapping>
        </bpmn:extensionElements>
        <bpmn:outgoing>Flow_001thyu</bpmn:outgoing>
        <bpmn:errorEventDefinition id="ErrorEventDefinition_02r4vna" />
      </bpmn:startEvent>
1 Like

Hello @scan - the Error Catch Event receives variables from the error event it is catching. For instance, if you have a Service Task and the job worker returns an error with the variable message defined, your catch event would work (and map message to the process variable ErrorMessage). Here’s an example of throwing an error with a variable in a Java job worker.

Hello Nathan

Thank you for your explanation and the example. As far as I can understand as a beginner, this is exactly what I do in Python.
In My Worker Task (1) I trigger the error with the message (2). In the REST CONNECTOR (3) under Error handling (4) I can access error.message (this expression works). But in the ERROR START EVENT (5) it is not possible for me (6) there comes the error

failed to evaluate expression ‘{ErrorMessage:error.message}’: no variable found for name ‘error’

or with only message the error

failed to evaluate expression ‘{ErrorMessage:message}’: no variable found for name ‘message’

I want to be able to write every error, no matter where it comes from (1,3,8), in a log (7).
Or is this loged by Camunda Enterprise itself and we can access it? Mybe even with an alirt?

Andreas

I am also having the same issue. Once the error boundary event has fired, there is no obvious way of getting the error details, i.e. the error status code (e.g. 404). The reason for wanting to do this is to pass the error details to a DMN decision to determine the next best action when the boundary error event is fired.

I have looked at adding the Output variable to the boundary event as the documentation implies we should do, but there is no indication as to the error object / property it should be mapped to.

In my case, I do not want to use a job worker to raise the exception and set the error details as has been suggested above.

Is there a solution to this or is this a bug?

Thanks for the info @scan and @Justin_Phillips … let me dig into this a bit more and see what I find!

Thanks for the patience @scan, @Justin_Phillips, and @Larry. And apologies for the confusion! I was confused myself, and hopefully this explanation makes sense.

There is currently an open issue with Zeebe related to mapping the error code and error message in the catch events (see here and here). In other words, those values aren’t available in the catch event, which is exactly what you’re experiencing!

However, if you send additional variables with the error, those variables are available and can be used in the output mapping. For instance, with the Java client, you would do something like this:

jobClient.newThrowErrorCommand(job)
.errorCode("creditCardChargeError")
.variables(Map.of("errorCode", "No more credit")) // <-- the important part
.errorMessage(e.getMessage()).send().join();

(Apologies, I am not familiar with pyZeebe so I don’t know to do that with Python off the top of my head!)

If another workaround is needed, you can set a process variable when throwing the error, and those variables will be available in the event and next task also.

I’ve shared this feedback with the engineering team, and I’m going to look at how we can improve our current documentation on this topic to avoid further confusion!

1 Like

Thanks for the update. I have been advised that a fix for this is being targeted for the 8.4 release.

1 Like

Thanks also for all the information. As far as I can see, there are only message and error_code parameters in pyZeebe. It’s a good idea to use a process variable, that can be a solution.
Meanwhile, I saw an example of good and bad design in https://page.camunda.com/camunda-community-summit-2023-combining-orchestration-and-choreography-for-a-clean-architecture.
So my BPMN example above, with different connectors, seems to be bad design. If we use only our own tasks, we can log all errors in Python and don’t have to worry about them in BPMN.
Process2