public static void SendToAppfail(this Exception e, HttpContextBase httpContext = null)
{
if (e == null)
{
return;
}
try
{
if (httpContext == null)
{
httpContext = new HttpContextWrapper(HttpContext.Current);
}
if (ConfigurationModel.Instance.DisableInDebugMode && httpContext.IsDebuggingEnabled)
{
// We are in debug mode, and should disable during debug mode, so exit and don't report the failure.
return;
}
var url = httpContext.Request.Url.AbsolutePath.ToString();
// The base exception is the true 'cause' of the error, this is what we report for the
// exception type, message and stack trace.
var baseException = e.GetBaseException();
if (!IsFilteredByFluentExpression(baseException, url) && !IsFilteredByWebConfig(baseException, url))
{
var failReport = FailOccurrenceFactory.FromException(httpContext, e);
FailQueue.Enqueue(failReport);
}
}
catch (Exception)
{
// Yes this is a catch-all exception, but warranted here. Appfail's reporting module
// should NEVER cause an unhandled exception. We can't be bringing down client applications.
}
}