Table of Contents

Class ProcessException

Namespace
Invex.Process
Assembly
Invex.Process.dll

The exception thrown by IProcessRunner when a process exits with a non-zero exit code and AllowFailedResult is false.

public sealed class ProcessException : Exception
Inheritance
object
Exception
ProcessException

Examples

Inspecting a failed run:

try
{
    processRunner.Run(new ProcessRunOptions("git", "rev-parse HEAD"));
}
catch (ProcessException ex) when (ex.ExitCode == 128)
{
    logger.LogWarning("Not a git repository: {Error}", ex.Result.Error);
}

Remarks

The System.Exception.Message describes the failure (command line, exit code, working directory when set, and any captured stderr), and Result exposes the full result of the failed run — including the captured stdout and stderr and the originating ProcessRunOptions — for programmatic inspection.

Derives directly from System.Exception, so existing catch (Exception) blocks continue to handle it.

Constructors

ProcessException(string, ProcessRunResult)

Initializes a new instance of ProcessException for a failed process run.

public ProcessException(string message, ProcessRunResult result)

Parameters

message string

The message that describes the failure.

result ProcessRunResult

The result of the failed process run.

Properties

ExitCode

Gets the non-zero exit code the process returned.

public int ExitCode { get; }

Property Value

int

Remarks

Shorthand for Result.ExitCode.

Result

Gets the result of the failed process run, including the captured stdout and stderr and the options the process was run with.

public ProcessRunResult Result { get; }

Property Value

ProcessRunResult