Is it okay to use Elmah instead of try/catch?

北城余情 提交于 2019-12-06 05:53:54

问题


I have been using Elmah for an MVC application and my question is

Is it a bad practice to not write try catch statement when using Elmah?


回答1:


ELMAH is used to log unhandled exceptions. If you can handle the exception I would strongly suggest that you do.

If you still want to log the exceptions to ELMAH, you can do so:

try {
  ...
}
catch (Exception e) {
  Elmah.ErrorSignal.FromCurrentContext().Raise(e)
}


来源:https://stackoverflow.com/questions/12598773/is-it-okay-to-use-elmah-instead-of-try-catch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!