public void OnError(object obj, EventArgs args) { // At this point we have information about the error log4net.ILog log = PtaUtil.getLog4netLogger(this.GetType().FullName + ".OnError(): "); log.Debug("Entered GlobalErrorHandler.OnError"); HttpContext ctx = HttpContext.Current; HttpResponse response = ctx.Response; HttpRequest request = ctx.Request; Exception exception = ctx.Server.GetLastError(); String ex_html = PtaUtil.GetExceptionAndEnvHtml(exception); String url = HttpContext.Current.Request.Url.ToString(); log.Debug("HttpContext.Current.Request.FilePath: " + HttpContext.Current.Request.FilePath); log.Debug("HttpContext.Current.Request.ApplicationPath: " + HttpContext.Current.Request.ApplicationPath); //!! test when proxy is not root if (HttpContext.Current.Request.FilePath.StartsWith( PtaUtil.GetProxyWebFolder() + PtaUtil.PTA_SUBFOLDER)) { log.Info(ex_html); } else { response.Write(ex_html); ctx.Server.ClearError(); // -------------------------------------------------- // To let the page finish running we clear the error // -------------------------------------------------- } }
public static void LogExceptionAndFormParameters(log4net.ILog log, Exception exception) { //just in case if we get some more exceptions during GetExceptionAndEnvHtml() log.Error(exception); //ex_html by itself will include exception info too, traced back to all InnerExceptions String ex_html = PtaUtil.GetExceptionAndEnvHtml(exception); log.Info(ex_html); }