Does elmah handle caught exceptions as well

烂漫一生 提交于 2019-11-28 15:57:51
Michael La Voie

ELMAH has been updated to support a new feature called Signaling.

This allows you to handle exceptions how you want, while still logging them to ELMAH.

try
{
    int i = 5;
    int j = 0;
    i = i / j; //Throws exception
}
catch (Exception ex)
{
    MyPersonalHandlingCode(ex);
    ErrorSignal.FromCurrentContext().Raise(ex); //ELMAH Signaling
}

Re-throwing exceptions can be a bad practice as it makes it difficult to trace the flow of an application. Using Signaling is a much better approach if you intended to handle the error in some fashion and simply want to document it.

Please check out this excellent guide by DotNetSlackers on ELMAH

Josh C

A filter is the cleanest way to handle this problem. Check this solution here https://stackoverflow.com/a/5936867/965935

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