Of course, a workflow might not execute flawlessly. Unexpected exceptions may arise because a database server might not be available, for instance. We can also intentionally raise an exception with a ThrowActivity
.
Managing exceptions inside a workflow is similar to managing exceptions in Visual Basic or C#. Composite activities can include fault handlers to catch exceptions. If an activity does not handle an exception that occurs, the runtime will let the exception propagate to the parent activity. This is similar to an exception moving up the call stack until the .NET runtime can locate an appropriate exception handler. If the runtime does not find a catch handler for a .NET application thread, the application terminates. If an exception occurs inside a workflow, and the runtime can find no fault handler to catch the exception, the runtime terminates the workflow and raises the WorkflowTerminated
event.
The FaultHandlerActivity
handles exceptions in Windows Workflow. We can view...