workflow-core icon indicating copy to clipboard operation
workflow-core copied to clipboard

OnStepErrorAsync, OnLifeCycleEventAsync

Open VictorioBerra opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe.

The following code throws the following thread error:

host.OnStepError += async (workflow, step, exception) =>
{
    logger.LogError(exception, "Step error detected in workflow {WorkFlowId} on step id {StepId}, stopping host.", workflow.Id, step.Id);
    MRE.Set();
    await host.StopAsync(cts.Token).ConfigureAwait(false);
};

ERROR - VSTHRD101Avoid using async lambda for a void returning delegate type, because any exceptions not handled by the delegate will crash the process

Describe the solution you'd like Allow events that can take a Task instead of void.

Describe alternatives you've considered Not awaiting:

host.OnStepError += (workflow, step, exception) =>
{
    logger.LogError(exception, "Step error detected in workflow {WorkFlowId} on step id {StepId}, stopping host.", workflow.Id, step.Id);
    MRE.Set();
    _ = host.StopAsync(cts.Token);
};

Additional context Add any other context or screenshots about the feature request here.

VictorioBerra avatar Mar 11 '22 17:03 VictorioBerra