views:

370

answers:

2

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.

+2  A: 

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

Macka
+3  A: 

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.

Mauricio Scheffer