Created
March 19, 2017 18:38
-
-
Save patkleef/eeb90abc771e86778897089f3a7b2dcb to your computer and use it in GitHub Desktop.
Application Insights Blog - ApplicationInsightsAiHandleErrorAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)] | |
public class AiHandleErrorAttribute : HandleErrorAttribute | |
{ | |
public override void OnException(ExceptionContext filterContext) | |
{ | |
if (filterContext != null && filterContext.HttpContext != null && filterContext.Exception != null) | |
{ | |
if (filterContext.HttpContext.IsCustomErrorEnabled) | |
{ | |
var ai = new TelemetryClient(); | |
ai.TrackException(filterContext.Exception); | |
} | |
} | |
base.OnException(filterContext); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment