Castle MonoRail & ELMAH

我们两清 提交于 2019-12-21 05:46:36

问题


Is anyone using Castle MonoRail and ELMAH with success?

We are using a number of Resuces to present users with friendly error messages, but if we do this the exceptions never get as far as ELMAH as the MonoRail rescue intercepts them.

Ideally we want the user to see the rescue, but for the exception to be logged in ELMAH.

Any ideas/pointers?

Cheers,

Jay.


回答1:


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.




回答2:


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:

  • http://code.google.com/p/elmah/wiki/DotNetSlackersArticle#Error_Signa...
  • http://code.google.com/p/elmah/wiki/DotNetSlackersArticle#Signaling_e...

-Atif



来源:https://stackoverflow.com/questions/275810/castle-monorail-elmah

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