Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Workflow Foundation 4 (WF4) Error Handling

What is the best way to get error messages from a WF4 workflow back to a hosting ASP.NET MVC application? I need the workflow to not terminate, but continue to be active, and then pass a message back to the hosting app regarding the error, so the user can take an alternative action, but I'm not sure how to do that.

like image 511
Russ Clark Avatar asked Mar 30 '10 12:03

Russ Clark


1 Answers

In order to keep your workflow alive you need to catch the exception in your workflow. Add a TryCatch activity to you workflow and in a Catch block you can use either a Send or a custom activity to send the data to the host application.

The one exception is to use the WorkflowApplication.OnUnhandledException with persistence and specify abort. In that case the in memory state of the workflow is just removed and the workflow can be reloaded for the last persisted state. If you go this way you need to make sure, using the Perist activity, that your workflow is saved whenever something that cannot be redone.

like image 95
Maurice Avatar answered Oct 06 '22 05:10

Maurice