ConvertExceptionTree() private static method

private static ConvertExceptionTree ( Exception exception, ExceptionDetails parentExceptionDetails, List exceptions ) : void
exception System.Exception
parentExceptionDetails ExceptionDetails
exceptions List
return void
        private void UpdateExceptions(Exception exception)
        {
            // collect the set of exceptions detail info from the passed in exception
            List <ExceptionDetails> exceptions = new List <ExceptionDetails>();

            ExceptionTelemetry.ConvertExceptionTree(exception, null, exceptions);

            // trim if we have too many, also add a custom exception to let the user know we're trimed
            if (exceptions.Count > MaxExceptionCountToSave)
            {
                // TODO: when we localize these messages, we should consider not using InvariantCulture
                // create our "message" exception.
                InnerExceptionCountExceededException countExceededException = new InnerExceptionCountExceededException(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        "The number of inner exceptions was {0} which is larger than {1}, the maximum number allowed during transmission. All but the first {1} have been dropped.",
                        exceptions.Count,
                        MaxExceptionCountToSave));

                // remove all but the first N exceptions
                exceptions.RemoveRange(MaxExceptionCountToSave, exceptions.Count - MaxExceptionCountToSave);

                // we'll add our new exception and parent it to the root exception (first one in the list)
                exceptions.Add(PlatformSingleton.Current.GetExceptionDetails(countExceededException, exceptions[0]));
            }

            this.Data.exceptions = exceptions;
        }
        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);
            }
        }