什么情况下可以使用ELMAH代替try / catch语句? [英] Is it okay to use Elmah instead of try/catch?
本文介绍了什么情况下可以使用ELMAH代替try / catch语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直使用 ELMAH 一个MVC应用程序,我的问题是
I have been using Elmah for an MVC application and my question is
这是个不好的做法,不写使用ELMAH时尝试catch语句?
Is it a bad practice to not write try catch statement when using Elmah?
推荐答案
ELMAH用于记录未处理的异常。如果你能处理异常,我强烈建议你这么做。
ELMAH is used to log unhandled exceptions. If you can handle the exception I would strongly suggest that you do.
如果你仍然要记录的例外ELMAH,你可以这样做:
If you still want to log the exceptions to ELMAH, you can do so:
try {
...
}
catch (Exception e) {
Elmah.ErrorSignal.FromCurrentContext().Raise(e)
}
这篇关于什么情况下可以使用ELMAH代替try / catch语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文