/// <summary> /// Converts a System.Exception to a Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryTypes.ExceptionDetails. /// </summary> internal static External.ExceptionDetails ConvertToExceptionDetails( Exception exception, External.ExceptionDetails parentExceptionDetails) { External.ExceptionDetails exceptionDetails = External.ExceptionDetails.CreateWithoutStackInfo( exception, parentExceptionDetails); var stack = new StackTrace(exception, true); var frames = stack.GetFrames(); Tuple <List <External.StackFrame>, bool> sanitizedTuple = SanitizeStackFrame( frames, GetStackFrame, GetStackFrameLength); exceptionDetails.parsedStack = sanitizedTuple.Item1; exceptionDetails.hasFullStack = sanitizedTuple.Item2; return(exceptionDetails); }
/// <summary> /// Creates a new instance of ExceptionDetails from a System.Exception and a parent ExceptionDetails. /// </summary> internal static ExceptionDetails CreateWithoutStackInfo(Exception exception, ExceptionDetails parentExceptionDetails) { if (exception == null) { throw new ArgumentNullException(nameof(exception)); } var exceptionDetails = new External.ExceptionDetails() { id = exception.GetHashCode(), typeName = exception.GetType().FullName, message = exception.Message }; if (parentExceptionDetails != null) { exceptionDetails.outerId = parentExceptionDetails.id; } return(exceptionDetails); }
/// <summary> /// Creates a new instance of ExceptionDetails from a System.Exception and a parent ExceptionDetails. /// </summary> internal static ExceptionDetails CreateWithoutStackInfo(Exception exception, ExceptionDetails parentExceptionDetails) { if (exception == null) { throw new ArgumentNullException("exception"); } var exceptionDetails = new External.ExceptionDetails() { id = exception.GetHashCode(), typeName = exception.GetType().FullName, message = exception.Message }; if (parentExceptionDetails != null) { exceptionDetails.outerId = parentExceptionDetails.id; } return exceptionDetails; }
/// <summary> /// Converts a System.Exception to a Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryTypes.ExceptionDetails. /// </summary> internal static External.ExceptionDetails ConvertToExceptionDetails( Exception exception, External.ExceptionDetails parentExceptionDetails) { External.ExceptionDetails exceptionDetails = External.ExceptionDetails.CreateWithoutStackInfo( exception, parentExceptionDetails); #if !WINRT && !CORE_PCL var stack = new StackTrace(exception, true); var frames = stack.GetFrames(); Tuple <List <External.StackFrame>, bool> sanitizedTuple = SanitizeStackFrame( frames, GetStackFrame, GetStackFrameLength); exceptionDetails.parsedStack = sanitizedTuple.Item1; exceptionDetails.hasFullStack = sanitizedTuple.Item2; #else if (exception.StackTrace != null) { string[] lines = exception.StackTrace.Split(new string[] { "\n" }, StringSplitOptions.None); // Adding 1 for length in lengthGetter for newline character Tuple <List <string>, bool> sanitizedTuple = SanitizeStackFrame( lines, (input, id) => input, (input) => input == null ? 0 : input.Length + 1); List <string> sanitizedStackLines = sanitizedTuple.Item1; exceptionDetails.hasFullStack = sanitizedTuple.Item2; exceptionDetails.stack = string.Join("\n", sanitizedStackLines.ToArray()); } else { exceptionDetails.hasFullStack = true; exceptionDetails.stack = string.Empty; } #endif return(exceptionDetails); }
public ExceptionDetails GetExceptionDetails(Exception exception, ExceptionDetails parentExceptionDetails) { return ExceptionConverter.ConvertToExceptionDetails(exception, parentExceptionDetails); }
private static void ConvertExceptionTree(Exception exception, ExceptionDetails parentExceptionDetails, List<ExceptionDetails> exceptions) { if (exception == null) { exception = new Exception(Utils.PopulateRequiredStringValue(null, "message", typeof(ExceptionTelemetry).FullName)); } ExceptionDetails exceptionDetails = PlatformSingleton.Current.GetExceptionDetails(exception, parentExceptionDetails); exceptions.Add(exceptionDetails); AggregateException aggregate = exception as AggregateException; if (aggregate != null) { foreach (Exception inner in aggregate.InnerExceptions) { ExceptionTelemetry.ConvertExceptionTree(inner, exceptionDetails, exceptions); } } else if (exception.InnerException != null) { ExceptionTelemetry.ConvertExceptionTree(exception.InnerException, exceptionDetails, exceptions); } }
public ExceptionDetails GetExceptionDetails(Exception exception, ExceptionDetails parentExceptionDetails) { return this.OnGetExceptionDetails(exception, parentExceptionDetails); }