Castle MonoRail & ELMAH

微笑、不失礼 提交于 2019-12-03 20:14:33

After looking at the links Macka posted, I wrote this simple monorail exception handler:

public class ElmahExceptionHandler : AbstractExceptionHandler {
    public override void Process(IRailsEngineContext context) {
        ErrorSignal.FromCurrentContext().Raise(context.LastException);
    }
}

Then I registered it in web.config, monorail section:

<monorail>
    <extensions>
        <extension type="Castle.MonoRail.Framework.Extensions.ExceptionChaining.ExceptionChainingExtension, Castle.MonoRail.Framework"/>
    </extensions>
    <exception>
        <exceptionHandler type="MyNamespace.ElmahExceptionHandler, MyAssembly"/>
    </exception>
...
</monorail>

And that's it.

After also posting on Google Groups it looks like Atif may have pointed me in the right direction.

You might want to look into error signaling in ELMAH. It is designed for scenarios where you want to pass an exception through ELMAH's pipeline even if it is being handled/swallowed. Here are some pointers to get started with error signaling:

-Atif

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