Example #1
0
        public static ProcessException GenerateException(this ProcessExitResultWithOutput exitResult)
        {
            var output = exitResult.StandardOutput +
                         "\nError: " + exitResult.StandardError;

            return(new ProcessException(GenerateMessage(exitResult) + "\nOutput: " + output)
            {
                Output = output
            });
        }
 static void ProcessExitResult(ProcessExitResultWithOutput result, TransferSpec spec) {
     switch (result.ExitCode) {
     case 0:
         break;
     case -1:
         throw new RsyncSoftProgramException(
             $"Aborted/Killed (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
     case 5:
         throw new RsyncSoftException(
             $"Server full (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
     case 10:
         throw new RsyncSoftException(
             $"Connection refused (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError,
             result.StartInfo.Arguments);
     case 12:
         throw new RsyncSoftException(
             $"Could not retrieve file (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
     case 14:
         throw new RsyncSoftException(
             $"Could not retrieve file due to IPC error (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
     case 23:
         throw new RsyncSoftException(
             $"Could not retrieve file (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
     case 24:
         throw new RsyncSoftException(
             $"Could not retrieve file (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
     case 30:
         throw new RsyncSoftException(
             $"Could not retrieve file due to Timeout (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
     case 35:
         throw new RsyncSoftException(
             $"Could not retrieve file due to Timeout (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
     case 35584:
         throw new RsyncSoftProgramException(
             $"Stackdump (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
     case -1073741819:
         throw new RsyncCygwinProgramException(
             $"Cygwin fork/rebase problem (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
     default:
         throw new RsyncException(
             $"Did not exit gracefully (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
     }
 }
 static void ProcessExitResult(ProcessExitResultWithOutput result, TransferSpec spec) {
     switch (result.ExitCode) {
     case 0:
         break;
     case -1:
         throw new RsyncSoftProgramException(
             $"Aborted/Killed (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
     case 35584:
         throw new RsyncSoftProgramException(
             $"Stackdump (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
     case -1073741819:
         throw new RsyncCygwinProgramException(
             $"Cygwin fork/rebase problem (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
     default:
         throw new RsyncException(
             $"Did not exit gracefully (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
             result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
     }
 }
 private static ProcessException BuildProcessException(ProcessStartInfo startInfo, string tool,
     ProcessExitResultWithOutput ret) => new ProcessException(
     string.Format("{6} [{7}] error: {0} while running: {1} {2} from {3}\nOutput: {4}\nError: {5}",
         ret.ExitCode,
         startInfo.FileName,
         startInfo.Arguments,
         startInfo.WorkingDirectory,
         ret.StandardOutput,
         ret.StandardError,
         tool ?? Path.GetFileNameWithoutExtension(startInfo.FileName),
         ret.Id));
 protected void HandleRsyncResponse(ProcessExitResultWithOutput response) {
     if (response.ExitCode == 0)
         return;
     throw new RsyncException(
         $"Rsync [{response.Id}] exited with code {response.ExitCode}\nOutput: {response.StandardOutput}\nError: {response.StandardError}");
 }
Example #6
0
 static void ProcessExitResult(ProcessExitResultWithOutput exitResult) {
     if (exitResult.ExitCode != 0)
         throw exitResult.GenerateException();
 }
        static void ProcessExitResult(ProcessExitResultWithOutput result, TransferSpec spec) {
            if (spec.Progress.ZsyncIncompatible) {
                throw new ZsyncIncompatibleException(
                    $"Zsync Incompatible (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
                    result.StandardOutput + result.StandardError,
                    result.StartInfo.Arguments);
            }

            switch (result.ExitCode) {
            case 0:
                break;
            case -1: {
                if (spec.Progress.ZsyncLoopCount >= 2) {
                    throw new ZsyncLoopDetectedException(
                        $"Loop detected, aborted transfer (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
                        result.StandardOutput + result.StandardError,
                        result.StartInfo.Arguments);
                }

                throw new ZsyncSoftProgramException(
                    $"Aborted/Killed (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
                    result.StandardOutput + result.StandardError,
                    result.StartInfo.Arguments);
            }
            case 1:
                throw new ZsyncSoftException(
                    $"Could not retrieve file due to protocol error (not a zsync file?) (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
                    result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
            case 2:
                throw new ZsyncSoftException(
                    $"Connection reset (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
                    result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
            case 3:
                var statusCode = FindStatusCode("" + result.StandardOutput + result.StandardError);
                try {
                    throw new ZsyncSoftException(
                        $"Could not retrieve file (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
                        result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
                } catch (ZsyncSoftException ex) {
                    switch (statusCode) {
                    case -1:
                        throw;
                    case 404:
                        throw new RequestFailedException("Received a 404: NotFound response", ex);
                    case 403:
                        throw new RequestFailedException("Received a 403: Forbidden response", ex);
                    case 401:
                        throw new RequestFailedException("Received a 401: Unauthorized response", ex);
                    }
                    throw;
                }
            case 21:
                throw new ZsyncSoftProgramException(
                    $"Retrieved file but could not rename (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
                    result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
            case 35584:
                throw new ZsyncSoftProgramException(
                    $"Stackdump (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
                    result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
            case -1073741819:
                throw new ZsyncCygwinProgramException(
                    $"Cygwin fork/rebase problem (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
                    result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
            default:
                throw new ZsyncException(
                    $"Did not exit gracefully (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}",
                    result.StandardOutput + result.StandardError, result.StartInfo.Arguments);
            }
        }