Beispiel #1
0
        private static void PrintError(Exception e)
        {
            switch (e)
            {
            case AggregateException ae:
                foreach (var ie in ae.InnerExceptions)
                {
                    PrintException(ie);
                }
                return;

            case TargetInvocationException _:
                e = e.InnerException;
                break;
            }

            if (ZCopyConfiguration.DisableAnsiConsole || (ZCopyConfiguration.Environment.DisableAnsiConsole ?? false))
            {
                PrintException(e);
            }
            else
            {
                PrintExceptionAnsi(e);
            }

            #region Local functions

            void PrintExceptionAnsi(Exception ex) =>
            ZCopyOutput.PrintError(ex.Message + " " + ex.InnerException?.Message);

            void PrintException(Exception ex) =>
            Helpers.Print(ex.Message + " " + ex.InnerException?.Message, color: ConsoleColor.Red);

            #endregion
        }
Beispiel #2
0
 private void FileOperationOnError(object sender, FileOperationErrorEventArgs e)
 {
     if (e.Exception is OperationCanceledException)
     {
         return;
     }
     ZCopyOutput.PrintError((e.Exception.Message + " " + e.Exception.InnerException?.Message).TrimEnd('\r', '\n'), false);
 }
        private void MtfoOnError(object sender, FileOperationErrorEventArgs e)
        {
            if (e.Exception is OperationCanceledException)
            {
                return;
            }

            lock (lockObj)
                ZCopyOutput.PrintError(e.Exception.Message + " " + e.Exception.InnerException?.Message);
        }
Beispiel #4
0
        private void FileOperationOnRetryStarted(object sender, FileOperationRetryStartedEventArgs e)
        {
            // Using a ThreadPool thread so that the caller is not blocked
            ThreadPool.QueueUserWorkItem(RetryIntervalProgressProc);

            void RetryIntervalProgressProc(object state)
            {
                var timer  = Stopwatch.StartNew();
                var format = $"{EscapeCodes.SavePosition()}{{0}}{EscapeCodes.RestorePosition()}";

                ZCopyOutput.PrintError(e.Reason.Message + " " + e.Reason.InnerException?.Message, false);

                while (timer.ElapsedMilliseconds < e.RetryInterval.TotalMilliseconds)
                {
                    ZCopyOutput.Print(format, $"Retrying in {e.RetryInterval - timer.Elapsed:mm\\mss\\s}");
                }

                timer.Stop();
                ZCopyOutput.Print();
            }
        }