danielgerlag / workflow-core

Lightweight workflow engine for .NET Standard
MIT License
5.39k stars 1.2k forks source link

How to properly terminate workflow when using ISyncWorkflowRunner.RunWorkflowSync? #657

Open chester89 opened 4 years ago

chester89 commented 4 years ago

Hello. I'm running workflows from inside ASP.NET Core app - launching it via ISyncWorkflowRunner.RunWorkflowSync and noticed some strange behaviour:

The reason I'm using ISyncWorkflowRunner is because I need to send workflow results back to the client. What I'd like is a way to say (perhaps for all my workflows) - "if there's an exception inside my step, please don't run the workflow further, let the app know". What is the proper way to achieve such behaviour?

chester89 commented 4 years ago

@danielgerlag can you suggest a workaround?

danielgerlag commented 4 years ago

It should terminate the workflow, but I don't think the unhandled exception would bubble up to the caller that started the workflow, you'd need to inspect the state of the workflow once the method returned, to determine if it was successful.

chester89 commented 4 years ago

@danielgerlag how can I determine the reason (exception) why the workflow failed? I only found WorkflowStatus on WorkflowInstance class - this is telling the end result (e.g. fail), not the reason

gineshdoruk commented 3 months ago

Hello! I have same problem. Any options for this case?