My custom rescue controller doesn't get called and exception bubbles out to ASP.NET

12 views
Skip to first unread message

jsmorris

unread,
Sep 10, 2008, 2:40:03 PM9/10/08
to Castle Project Users
My Controller

[ControllerDetails(Area = "admin")]
[Rescue(typeof(RescueController))]
public class FeedController : TraXController {...}

My custom rescue controller

[Layout("default")]
[Filter(ExecuteWhen.BeforeAction, typeof(AddTitleFilter))]
public class RescueController : Controller, IRescueController
{
public void Index() {...}
public void Rescue(Exception exception, IController
controller, IControllerContext controllerContext) {...}
}

Now, if I manually throw an error in one of my actions inside my
FeedController, all I get is the ASP.NET error page. I never hit my
breakpoint that I have set inside my RescueController.Rescue() method.

So, if I go back to marking my controller

[ControllerDetails(Area = "admin")]
[Rescue("error")]
public class FeedController : TraXController {...}

It all works great. I see my rescues/error.brail view.

Anyone see anything obvious that I might not be doing or know of
something I should be doing and I am not?

I am creating a custom rescue controller in order to log and email
error messages as the users sees them.

jsmorris

unread,
Sep 10, 2008, 8:26:06 PM9/10/08
to Castle Project Users
To answer my own question...

My difficulty was that my RescueController inherited from Controller,
but it should have inherited from SmartDispatcherController in order
to populate the arguments that are defined on Rescue method on the
IRescueController interface.

My controller now looks like

public class RescueController : SmartDispatcherController,
IRescueController
{
public void Rescue(Exception exception, IController
controller, IControllerContext controllerContext) {...}
}

Maybe this was blatantly obvious to everyone else, but it wasn't to
me.

Jason
Reply all
Reply to author
Forward
0 new messages