Exemplo n.º 1
0
        private static void ReportAppException(ExternalOperationException exception, bool isTerminating)
        {
            // UserExternalOperationException wraps an actual exception, but be cautious just in case
            string instructionText = exception.InnerException?.Message ?? GitUI.Strings.InstructionOperationFailed;

            ShowException(FormatText(exception, canRaiseBug: true), instructionText, exception, isTerminating);
        }
Exemplo n.º 2
0
        private static string FormatText(ExternalOperationException exception, bool canRaiseBug)
        {
            StringBuilder sb = new();

            // Command: <command>
            if (!string.IsNullOrWhiteSpace(exception.Command))
            {
                sb.AppendLine($"{GitUI.Strings.Command}: {exception.Command}");
            }

            // Arguments: <args>
            if (!string.IsNullOrWhiteSpace(exception.Arguments))
            {
                sb.AppendLine($"{GitUI.Strings.Arguments}: {exception.Arguments}");
            }

            // Working directory: <working dir>
            sb.AppendLine($"{GitUI.Strings.WorkingDirectory}: {exception.WorkingDirectory}");

            if (canRaiseBug)
            {
                // Directions to raise a bug
                sb.AppendLine();
                sb.AppendLine(GitUI.Strings.ReportBug);
            }

            return(sb.ToString());
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserExternalOperationException"/> class with a specified parameters
 /// and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="context">The command that led to the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception.</param>
 public UserExternalOperationException(string context, ExternalOperationException innerException)
     : base(innerException.Command, innerException.Arguments, innerException.WorkingDirectory, innerException.InnerException)
 {
     Context = context;
 }