Throwing and Handling BPMN Errors in .NET

Hi everyone,

I’m using CamundaClient.dll and using that to write external task services for BPMN tasks. However, I’d like to know how can we throw and handle BPMN error using the .NET Client?

Here’s how I’m handling it but it gives the following error as well.

[ExternalTaskTopic("TurnstilesInEmergencyMode")]
[ExternalTaskVariableRequirements("locationId")]
public class TurnstilesInEmergencyModeAdapter : IExternalTaskAdapter
{
  
    public void Execute(ExternalTask externalTask, ref Dictionary<string, object> resultVariables)
    {
        // get location 
        string locationId = string.Empty;

        try
        {
            locationId = (string)externalTask.Variables["locationId"].Value;

        }
        catch (KeyNotFoundException ex)
        {
           
            CamundaClient.ExternalTaskService.Error(externalTask.WorkerId, externalTask.Id, "KEY_NOT_FOUND");
            
            return;

        }


    }

}

EngineException: Could not report failure for external Task:

image

Any example would be highly appreciated. Thank you.

Hi @hello.aliasad,

you have to throw a new UnrecoverableBusinessErrorException like here:

Hope this helps, Ingo

1 Like