问题
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