How to catch unhandled exceptions in a page
This will allow you to make sure all the errors encountered at the top level get logged.
private void Page_Error(object sender, System.EventArgs e)
{
Exception ep = Server.GetLastError();
LogFile.LogFatal(Util.FormatExceptionError("Page_Error","top level error", ep,4));
//Server.ClearError(); //we don't clear, but let the system produce message
}
To have the above run, it must be registered as a callback
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
this.Error += new System.EventHandler(this.Page_Error);
}