@@ -15,7 +15,62 @@ public class ExitCodeReadException : ExitCodeException
1515 /// <param name="exitCode">The exit code of the command.</param>
1616 /// <param name="standardOutput">The contents of standard output (stdout).</param>
1717 /// <param name="standardError">The contents of standard error (stderr).</param>
18- public ExitCodeReadException ( int exitCode , string standardOutput , string standardError ) : base ( exitCode ) => ( StandardOutput , StandardError ) = ( standardOutput , standardError ) ;
18+ public ExitCodeReadException ( int exitCode , string standardOutput , string standardError ) :
19+ base ( exitCode , CreateMessage ( exitCode , standardOutput , standardError ) )
20+ {
21+ StandardOutput = standardOutput ;
22+ StandardError = standardError ;
23+ }
24+
25+ /// <summary>
26+ /// Constructs an instance of a <see cref="ExitCodeReadException"/>.
27+ /// </summary>
28+ /// <param name="exitCode">The exit code of the command.</param>
29+ /// <param name="standardOutput">The contents of standard output (stdout).</param>
30+ /// <param name="standardError">The contents of standard error (stderr).</param>
31+ /// <param name="innerException">
32+ /// The exception that is the cause of the current exception,
33+ /// or a <c>null</c> reference (<c>Nothing</c> in Visual Basic) if no inner exception is specified.
34+ /// </param>
35+ public ExitCodeReadException ( int exitCode , string standardOutput , string standardError , Exception innerException ) :
36+ base ( exitCode , CreateMessage ( exitCode , standardOutput , standardError ) , innerException )
37+ {
38+ StandardOutput = standardOutput ;
39+ StandardError = standardError ;
40+ }
41+
42+ /// <summary>
43+ /// Constructs an instance of a <see cref="ExitCodeReadException"/>.
44+ /// </summary>
45+ /// <param name="exitCode">The exit code of the command.</param>
46+ /// <param name="standardOutput">The contents of standard output (stdout).</param>
47+ /// <param name="standardError">The contents of standard error (stderr).</param>
48+ /// <param name="message">The message that describes the error.</param>
49+ public ExitCodeReadException ( int exitCode , string standardOutput , string standardError , string message ) :
50+ base ( exitCode , message )
51+ {
52+ StandardOutput = standardOutput ;
53+ StandardError = standardError ;
54+ }
55+
56+ /// <summary>
57+ /// Constructs an instance of a <see cref="ExitCodeReadException"/>.
58+ /// </summary>
59+ /// <param name="exitCode">The exit code of the command.</param>
60+ /// <param name="standardOutput">The contents of standard output (stdout).</param>
61+ /// <param name="standardError">The contents of standard error (stderr).</param>
62+ /// <param name="message">The message that describes the error.</param>
63+ /// <param name="innerException">
64+ /// The exception that is the cause of the current exception,
65+ /// or a <c>null</c> reference (<c>Nothing</c> in Visual Basic) if no inner exception is specified.
66+ /// </param>
67+ public ExitCodeReadException (
68+ int exitCode , string standardOutput , string standardError , string message , Exception innerException ) :
69+ base ( exitCode , message , innerException )
70+ {
71+ StandardOutput = standardOutput ;
72+ StandardError = standardError ;
73+ }
1974
2075 /// <summary>
2176 /// Gets the contents of standard output (stdout).
@@ -27,7 +82,13 @@ public class ExitCodeReadException : ExitCodeException
2782 /// </summary>
2883 public string StandardError { get ; }
2984
30- /// <inheritdoc/>
31- public override string Message =>
32- $ "{ base . Message } { TwoNewLines } Standard output (stdout):{ TwoNewLines } { StandardOutput } { TwoNewLines } Standard error (stderr):{ TwoNewLines } { StandardError } ";
85+ /// <summary>
86+ /// Create the message that describes the error.
87+ /// </summary>
88+ /// <param name="exitCode">The exit code of the command.</param>
89+ /// <param name="standardOutput">The contents of standard output (stdout).</param>
90+ /// <param name="standardError">The contents of standard error (stderr).</param>
91+ /// <returns>The message that describes the error</returns>
92+ protected static string CreateMessage ( int exitCode , string standardOutput , string standardError ) =>
93+ $ "{ CreateMessage ( exitCode ) } { TwoNewLines } Standard output (stdout):{ TwoNewLines } { standardOutput } { TwoNewLines } Standard error (stderr):{ TwoNewLines } { standardError } ";
3394}
0 commit comments