public void OnError(HttpContext context)
{
if (this.telemetryClient == null)
{
throw new InvalidOperationException("Initialize has not been called on this module yet.");
}
if (context == null)
{
WebEventSource.Log.NoHttpContextWarning();
return;
}
var errors = context.AllErrors;
if (errors != null && errors.Length > 0)
{
foreach (Exception exp in errors)
{
var exceptionTelemetry = new ExceptionTelemetry(exp);
if (context.Response.StatusCode >= 500)
{
exceptionTelemetry.SeverityLevel = SeverityLevel.Critical;
}
this.telemetryClient.TrackException(exceptionTelemetry);
}
}
}