How to manage some variables in throw error command

Hi everyone,
I hope you can help me, I have a question about error management. :smiley:

I’m working with zeebe with the C# client, and two workers than call a RESTful API. My model is this one :

I have some trouble, because when my API return an HTTP error (for good reason), I want to give the HTTP error code (HTTP 404 for example) to the caller. But I don’t understand how I can send some information about my error when I throw it.

So, here, I create my workflow instance, and wait for my results :

var output = await Client.NewCreateProcessInstanceCommand()
    .BpmnProcessId(ProcessJobTypeBpmId)
    .LatestVersion()
    .Variables($"{{\"input\":{JsonConvert.SerializeObject(input, TransactionConstants.Settings)}}}")
    .WithResult()
    .FetchVariables()
    .Send(token);

My worker A will send an error like this :

await client.NewThrowErrorCommand(job.Key).ErrorCode("1").ErrorMessage(e.Message).Send();

After this call, my workflow stop this execution, and return to the caller. But I have nothing in my output variable (not even the error message).

I wonder, how I can have some information about my throw ? Currently, I just know I have some error due to the missing output variable I need.

If you can help me, I will be very happy ! Thanks ! :slight_smile:

Hey @aroquemaurel

I think this is related to an open feature request Save/extract error code, error message (and variables) to variables in Error Catch Boundary Event · Issue #4337 · camunda-cloud/zeebe · GitHub

What do you think?

Greets
Chris

1 Like

Hi @Zelldon,
Thanks for your quick answer.

Yes, this request seems to be exactly what I need.
As long this feature is not merged, what can I do to fix my issue ?

Thanks,

1 Like

I think it depends what you want to achieve. You could add output mappings, which are setting the error code as variable or a specific message. You could also avoid bpmn errors and do it via results of the worker and exclusive gateways.

I had to do something similar to make sure what the output of the call activity is stored, see https://raw.githubusercontent.com/zeebe-io/zeebe-cluster-testbench/develop/docs/assets/chaosExperiment.png Related process zeebe-cluster-testbench/chaosExperiment.bpmn at develop · zeebe-io/zeebe-cluster-testbench · GitHub

Hope that helps.

Greets
Chris

1 Like

Thanks a lot @Zelldon for your answer.

Your idea is quiet good, and It is what I have implemented for this problem, it works. :slight_smile:

Antoine

1 Like