在 Windows 工作流中的 FaultHandler 活动中要捕获哪些异常

发布于 2024-08-11 15:47:22 字数 169 浏览 6 评论 0原文

我现在正在学习 Windows 工作流,现在正在研究状态机中的异常处理。 基本上我可以看到,FaultHandler 可用于捕获活动中引发的特定异常。 我的问题是我是否需要专门捕获每种类型的异常,或者是否有一种方法可以使用一个故障处理程序捕获所有异常? 我确信这不是最佳实践(有什么建议吗?),但只是有兴趣更好地理解它。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风筝在阴天搁浅。 2024-08-18 15:47:22

您应该明确捕获您认为可能发生的异常。

您可以有一个处理基Exception 类的通用异常,但这可能会隐藏代码中的问题。您需要记录所有异常,并通过某种方式让用户知道出现了问题,并将此信息返回给您,以便您可以纠正问题。

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.

眼泪也成诗 2024-08-18 15:47:22

如果将FaultType 设置为System.Exception,则可以捕获所有异常。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文