Skip to content

Commit

Permalink
Split out a ChildProcessErrorException class from ChildProcessException.
Browse files Browse the repository at this point in the history
The former will be for non-zero exit codes, the latter for actual exceptions.
  • Loading branch information
alexrp committed Jan 8, 2024
1 parent 5dfa165 commit f0d7337
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/core/Processes/ChildProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ internal ChildProcess(ChildProcessBuilder builder)
var code = _process.ExitCode;
_ = throwOnError && code != 0
? _completion.TrySetException(new ChildProcessException($"Process exited with code {code}.", code))
? _completion.TrySetException(new ChildProcessErrorException($"Process exited with code {code}.", code))
: _completion.TrySetResult(code);
if (terminal)
Expand Down
27 changes: 27 additions & 0 deletions src/core/Processes/ChildProcessErrorException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace Vezel.Cathode.Processes;

public class ChildProcessErrorException : ChildProcessException
{
public int ExitCode { get; }

public ChildProcessErrorException()
: this("An unknown child process error occurred.")
{
}

public ChildProcessErrorException(string? message)
: base(message)
{
}

public ChildProcessErrorException(string? message, int exitCode)
: this(message)
{
ExitCode = exitCode;
}

public ChildProcessErrorException(string? message, Exception? innerException)
: base(message, innerException)
{
}
}
10 changes: 1 addition & 9 deletions src/core/Processes/ChildProcessException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ namespace Vezel.Cathode.Processes;

public class ChildProcessException : Exception
{
public int ExitCode { get; }

public ChildProcessException()
: this("An unknown child process error occurred.")
: this("An unknown child process exception occurred.")
{
}

Expand All @@ -14,12 +12,6 @@ public ChildProcessException(string? message)
{
}

public ChildProcessException(string? message, int exitCode)
: this(message)
{
ExitCode = exitCode;
}

public ChildProcessException(string? message, Exception? innerException)
: base(message, innerException)
{
Expand Down

0 comments on commit f0d7337

Please sign in to comment.