winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

RunCommandException.cs (1796B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="RunCommandException.cs" company="Microsoft Corporation">
      3 //     Copyright (c) Microsoft Corporation. Licensed under the MIT License.
      4 // </copyright>
      5 // -----------------------------------------------------------------------------
      6 
      7 namespace AppInstallerCLIE2ETests
      8 {
      9     using System;
     10     using static AppInstallerCLIE2ETests.Helpers.TestCommon;
     11 
     12     /// <summary>
     13     /// An exception that occurred when running a command.
     14     /// </summary>
     15     internal class RunCommandException : Exception
     16     {
     17         /// <summary>
     18         /// Initializes a new instance of the <see cref="RunCommandException"/> class.
     19         /// </summary>
     20         /// <param name="fileName">The file name of the command.</param>
     21         /// <param name="args">The arguments for the command.</param>
     22         /// <param name="result">The `RunCommand` result.</param>
     23         public RunCommandException(string fileName, string args, RunCommandResult result)
     24             : base($"Command `{fileName} {args}` failed with: {result.ExitCode}\nOut: {result.StdOut}\nErr: {result.StdErr}")
     25         {
     26             this.FileName = fileName;
     27             this.Arguments = args;
     28             this.Result = result;
     29         }
     30 
     31         /// <summary>
     32         /// Gets or initializes the file name.
     33         /// </summary>
     34         public string FileName { get; private init; }
     35 
     36         /// <summary>
     37         /// Gets or initializes the arguments.
     38         /// </summary>
     39         public string Arguments { get; private init; }
     40 
     41         /// <summary>
     42         /// Gets or initializes the result object.
     43         /// </summary>
     44         public RunCommandResult Result { get; private init; }
     45     }
     46 }