protected virtual void Application_Error(object sender, EventArgs e)
{
Exception exception = this.Server.GetLastError();
if (exception == null)
return;
if (exception is ThreadAbortException)
return;
log.Fatal(exception.Message, exception);
StringBuilder html = new StringBuilder();
TextWriter writer = new StringWriter(html);
SageContext context = new SageContext(this.Context);
SageException sageException = SageHelpException.Create(exception);
if (((SageHelpException) sageException).Problem.Type == ProblemType.Unknown)
sageException = exception is SageHelpException
? (SageHelpException) exception
: new SageException(exception);
if (this.IsRequestAvailable)
{
sageException.Render(writer, context);
}
else
{
sageException.RenderWithoutContext(writer);
}
writer.Close();
writer.Dispose();
this.Response.ContentType = "text/html";
this.Response.Write(html.ToString());
this.Response.Cache.SetCacheability(HttpCacheability.NoCache);
this.Response.Cache.SetNoStore();
this.Response.End();
}