private void HandleException()

in src/PowerShell/Commands/ResolvePartnerError.cs [70:97]


        private void HandleException(Exception exception, ErrorRecord record)
        {
            if (exception == null)
            {
                WriteObject(new PartnerErrorRecord(record));
            }

            if (exception is AggregateException aggregateException)
            {
                foreach (Exception innerException in aggregateException.InnerExceptions.Where(e => e != null))
                {
                    HandleException(innerException, record);
                }
            }
            else if (exception is PartnerException)
            {
                WriteObject(new PartnerRestExceptionRecord(exception as PartnerException, record));
            }
            else
            {
                WriteObject(new PartnerExceptionRecord(exception, record));

                if (exception.InnerException != null)
                {
                    HandleException(exception.InnerException, record);
                }
            }
        }