FrmError & GlobalErrorHandler: Show InnerExceptions
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using Scrummer.Code.Pages;
|
||||
|
||||
@@ -12,28 +13,39 @@ namespace Scrummer.Code
|
||||
{
|
||||
context.Response.StatusCode = 500;
|
||||
context.Response.Clear();
|
||||
context.Response.Write("<h2>Internal error</h2>");
|
||||
context.Response.Write(String.Format("<p><b>Message:</b> {0}</p>", ex.Message));
|
||||
context.Response.Write(String.Format("<p><b>StackTrace:</b></p> <pre><code>{0}</code></pre>", ex.StackTrace));
|
||||
|
||||
StringBuilder sbOutput = new StringBuilder();
|
||||
sbOutput.Append("<h2>Internal error</h2>");
|
||||
Exception exAux = ex;
|
||||
if (exAux is HttpUnhandledException && exAux.InnerException != null) { exAux = exAux.InnerException; }
|
||||
while (exAux != null)
|
||||
{
|
||||
sbOutput.AppendFormat("<p><b>Message:</b> {0}</p>", exAux.Message);
|
||||
sbOutput.AppendFormat("<p><b>StackTrace:</b></p> <pre><code>{0}</code></pre>", exAux.StackTrace);
|
||||
exAux = exAux.InnerException;
|
||||
}
|
||||
|
||||
// Fill response to 512 bytes to avoid browser "beauty" response of errors.
|
||||
long fillResponse = 512 - (ex.Message.Length + ex.StackTrace.Length); ;
|
||||
long fillResponse = 512 - sbOutput.Length;
|
||||
if (fillResponse > 0)
|
||||
{
|
||||
context.Response.Write("<!--");
|
||||
sbOutput.Append("<!--");
|
||||
for (int i = 0; i < fillResponse; i++)
|
||||
{
|
||||
context.Response.Write("A");
|
||||
sbOutput.Append("A");
|
||||
}
|
||||
context.Response.Write("-->");
|
||||
sbOutput.Append("-->");
|
||||
}
|
||||
|
||||
context.Response.Write(sbOutput.ToString());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
|
||||
public static void HandleError(HttpContext context,Exception ex){
|
||||
public static void HandleError(HttpContext context, Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
IHttpHandler frmError = new FrmError(ex);
|
||||
|
||||
@@ -18,24 +18,31 @@ namespace Scrummer.Code.Pages
|
||||
|
||||
void FrmError_Init(object sender, EventArgs e)
|
||||
{
|
||||
Title = "Error";
|
||||
Title = "Application Error";
|
||||
|
||||
CLabel lblErrorTitle = new CLabel { Text = "Error", Tag = "h2" };
|
||||
CLabel lblErrorTitle = new CLabel { Text = Title, Tag = "h2" };
|
||||
Controls.Add(lblErrorTitle);
|
||||
|
||||
Exception exAux = _ex;
|
||||
if (exAux is HttpUnhandledException && exAux.InnerException != null) { exAux = exAux.InnerException; }
|
||||
while (exAux != null)
|
||||
{
|
||||
CLabel lblMessage = new CLabel { Tag = "P" };
|
||||
lblMessage.Text = String.Format("<b>{0}:</b> {1}", "Message", HttpUtility.HtmlEncode(exAux.Message));
|
||||
Controls.Add(lblMessage);
|
||||
|
||||
CLabel lblMessage = new CLabel { Tag = "P" };
|
||||
lblMessage.Text = String.Format("<b>{0}:</b> {1}", "Message",HttpUtility.HtmlEncode(_ex.Message));
|
||||
Controls.Add(lblMessage);
|
||||
CLabel lblStacktraceTitle = new CLabel { Tag = "p" };
|
||||
lblStacktraceTitle.Text = String.Format("<b>{0}:</b>", "Stacktrace");
|
||||
Controls.Add(lblStacktraceTitle);
|
||||
Panel pnlStacktrace = new Panel();
|
||||
pnlStacktrace.CssClass = "divCode";
|
||||
Controls.Add(pnlStacktrace);
|
||||
LiteralControl litStackTrace = new LiteralControl(
|
||||
String.Format("<pre><code>{0}</code></pre>", HttpUtility.HtmlEncode(exAux.StackTrace)));
|
||||
pnlStacktrace.Controls.Add(litStackTrace);
|
||||
|
||||
CLabel lblStacktraceTitle = new CLabel { Tag = "p" };
|
||||
lblStacktraceTitle.Text = String.Format("<b>{0}:</b>", "Stacktrace");
|
||||
Controls.Add(lblStacktraceTitle);
|
||||
Panel pnlStacktrace = new Panel();
|
||||
pnlStacktrace.CssClass = "divCode";
|
||||
Controls.Add(pnlStacktrace);
|
||||
LiteralControl litStackTrace = new LiteralControl(
|
||||
String.Format("<pre><code>{0}</code></pre>", HttpUtility.HtmlEncode(_ex.StackTrace)));
|
||||
pnlStacktrace.Controls.Add(litStackTrace);
|
||||
exAux = exAux.InnerException;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user