user176591
user176591

Reputation:

Which exceptions to catch in a FaultHandler activity in Windows Workflow

Im learning Windows Workflow at the minute and am now looking at exception handling in state machines. Basically I can see that a FaultHandler can be used to catch a specific exception thrown in an activity. My question is do I need to specifically catch each type of exception or is there a way I can catch all exceptions with one FaultHandler? Im sure this isn't best practice(any suggestions there?), but just interested to understand it a bit better.

Upvotes: 0

Views: 591

Answers (2)

ChrisF
ChrisF

Reputation: 137188

You should explicitly catch the exceptions you think might occur.

You could have a general purpose exception that handled the base Exception class, but that would potentially hide problems with your code. You would need to log all exceptions and have some way of both letting the user know that there had been a problem and getting this information back to you so that you can correct the problem.

Upvotes: 1

Henrik Gering
Henrik Gering

Reputation: 1891

You can catch all if you set the FaultType to System.Exception.

Upvotes: 0

Related Questions