Is Umbraco intercepting exceptions at a deeper level, before the page "sees" them? Or is this lack of firing due to the fact that the code is on a masterpage, not a page?
It seems the issue is not with Umbraco, but rather with how masterpages work. The OnError() handler for a masterpage doesn't get called when there's an error on the page it defines.
However, you can add an event handler (on every page load) to call a Page_Error routine which in turn calls OnError():
protected override void OnLoad( EventArgs e ) { base.OnLoad(e);
this.Page.Error += new EventHandler(Page_Error); }
protected void Page_Error( object sender, EventArgs e ) { }
Catching Exceptions on a Master Page
I'm trying to catch, and handle, some database exceptions on a masterpage I've created. I've tried adding the following to the masterpage codebehind:
public void PageError( object sender, EventArgs e )
{
int i = 9;
i++;
}
protected override void HandleException( PageExceptionArgs args )
{
base.HandleException(args);
}
Neither of these methods ever get called.
Is Umbraco intercepting exceptions at a deeper level, before the page "sees" them? Or is this lack of firing due to the fact that the code is on a masterpage, not a page?
- Mark
It seems the issue is not with Umbraco, but rather with how masterpages work. The OnError() handler for a masterpage doesn't get called when there's an error on the page it defines.
However, you can add an event handler (on every page load) to call a Page_Error routine which in turn calls OnError():
protected override void OnLoad( EventArgs e )
{
base.OnLoad(e);
this.Page.Error += new EventHandler(Page_Error);
}
protected void Page_Error( object sender, EventArgs e )
{
}
Which works well enough.
- Mark
is working on a reply...