How can I get the exception name or exception code from ERROR BOUNDARY EVENT.

How can I get the exception name or exception code from ERROR BOUNDARY EVENT.
Снимок экрана 2023-11-01 в 18.01.06

Hi @Ramazan :wave: and welcome to your forums!

When you throw an error for a job, you can pass variables along. You can merge the variables into your process using output mappings on the catching error boundary event.

@ korthout And how can I get this variable in the following service task in the input?My task is to get the exception name or code to recognise which process gave the error boundary.
Снимок экрана 2023-11-02 в 16.31.11

@Ramazan You can achieve this in multiple steps. Note that I’ve renamed the variable in each step to clarify what each mapping achieves:

  1. First, you throw an error with a variable, e.g. my_exception.
  2. Then, use an output mapping on the error boundary event to merge this variable into the process, e.g. target: caught_AML_error and source: = my_exception (it now exists at the process instance level which makes it visible to any element in the process)
  3. Then, use an input mapping on the service task to pass the variable to the job handler, e.g. target: error_to_handle and source: = caught_AML_error
  4. You can now use the variable error_to_handle in your job worker.

Note that the error message and error code cannot be directly extracted from the caught error yet. You need to explicitly pass them as variables in order to use them in variable mappings and your job worker. There is an open feature request to allow this: Use Expression Contexts to provide caught error code and message to expressions · Issue #11459 · camunda/zeebe · GitHub