Exemplo n.º 1
0
        private void ConvertExceptionTree(Exception exception, string message, TelemetryExceptionDetails parentExceptionDetails, List <TelemetryExceptionDetails> exceptions)
        {
            // For upper level exception see if message was provided and do not use exception.message in that case
            if (parentExceptionDetails != null && string.IsNullOrWhiteSpace(message))
            {
                message = exception?.Message;
            }

            TelemetryExceptionDetails exceptionDetails = new TelemetryExceptionDetails(exception, message,
                                                                                       parentExceptionDetails);

            exceptions.Add(exceptionDetails);

            if (exception is AggregateException aggregate)
            {
                foreach (Exception inner in aggregate.InnerExceptions)
                {
                    ConvertExceptionTree(inner, null, exceptionDetails, exceptions);
                }
            }
            else if (exception.InnerException != null)
            {
                ConvertExceptionTree(exception.InnerException, null, exceptionDetails, exceptions);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of ExceptionDetails from a System.Exception and a parent ExceptionDetails.
        /// </summary>
        internal TelemetryExceptionDetails(Exception exception, string message, TelemetryExceptionDetails parentExceptionDetails) : this(message)
        {
            if (exception == null)
            {
                throw new ArgumentNullException(nameof(exception));
            }

            Id       = exception.GetHashCode();
            TypeName = exception.GetType().FullName;

            if (parentExceptionDetails != null)
            {
                OuterId = parentExceptionDetails.Id;
            }

            var stack = new StackTrace(exception, true);

            var frames = stack.GetFrames();
            Tuple <List <StackFrame>, bool> sanitizedTuple = SanitizeStackFrame(frames, GetStackFrame, GetStackFrameLength);
            ParsedStack  = sanitizedTuple.Item1;
            HasFullStack = sanitizedTuple.Item2;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new instance of ExceptionDetails from a System.Exception and a parent ExceptionDetails.
        /// </summary>
        internal TelemetryExceptionDetails(Exception exception, string message, TelemetryExceptionDetails parentExceptionDetails)
        {
            if (exception == null)
            {
                throw new ArgumentNullException(nameof(exception));
            }
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            this.Message  = message.Truncate(SchemaConstants.ExceptionDetails_Message_MaxLength);
            this.Id       = exception.GetHashCode();
            this.TypeName = exception.GetType().FullName.Truncate(SchemaConstants.ExceptionDetails_TypeName_MaxLength);

            if (parentExceptionDetails != null)
            {
                this.OuterId = parentExceptionDetails.Id;
            }

            this.ParsedStack  = GetSanitizedStackFrame(exception, out bool hasFullStack);
            this.HasFullStack = hasFullStack;
        }