Skip to content

ExitCodeOptions

Maps ReplExecutionOutcomeKind categories to process exit codes and exposes a final interception point. Applies to top-level runs only; nested sub-invocations use the built-in defaults.

public sealed class ExitCodeOptions

Gets or sets the exit code for BindingError. Default 2.

public int BindingError { get; set; }

int

Gets or sets the exit code for Cancelled — a run stopped through the caller’s own CancellationToken, whether during the command, while an interactive session waits for input, or while hosted services were starting. When null (the default) the OperationCanceledException propagates to the caller instead of being converted, unless a Resolver is set, which also opts in to observing cancellation — the resolver is then handed 130, the shell convention for 128 + SIGINT. A handler that raises OperationCanceledException without the caller having asked for cancellation is a failure, reported as HandlerException.

public int? Cancelled { get; set; }

int?

Gets or sets the exit code for CompletedWithFailures. Default 1, the code test runners such as pytest use when tests fail; Microsoft.Testing.Platform uses 2. The default is shared with HandlerError and HandlerException: give it a code of its own when a script must tell a run with failures from a failed command.

public int CompletedWithFailures { get; set; }

int

Gets or sets the exit code for FrameworkError. Default 1.

public int FrameworkError { get; set; }

int

Gets or sets the exit code for HandlerError. Default 1.

public int HandlerError { get; set; }

int

Gets or sets the exit code for HandlerException. Default 1.

public int HandlerException { get; set; }

int

Gets or sets the exit code for Help. Default 0; set it non-zero when a bare invocation must fail in scripted pipelines.

public int Help { get; set; }

int

Gets or sets the exit code for Interrupted — a process signal (SIGINT, Ctrl+Break, SIGTERM) turned into a cooperative shutdown by a process-signal handler — ReplRunOptions.ProcessSignalHandling in automatic mode claims the signal and reports the run as interrupted.

When null (the default) the conventional 128 + signal code the claimed signal carries is used — 130 for SIGINT and Ctrl+Break, 143 for SIGTERM — falling back to 130 when none is supplied. Set this to publish a single code for every signal instead. A run that had already produced its own refusal or failure keeps reporting that instead of the interruption; only a clean or cancelled run is reclassified.

public int? Interrupted { get; set; }

int?

Gets or sets a final interception hook invoked with the structured outcome (whose ExitCode already reflects the codes the command’s module declares through IReplModuleExitCodes, then this table); its return value becomes the exit code.

public Func<ReplExecutionOutcome, int>? Resolver { get; set; }

Func<ReplExecutionOutcome, int>

Gets or sets the exit code for Success. Default 0.

public int Success { get; set; }

int

Gets or sets the exit code for UsageError. Default 2.

public int UsageError { get; set; }

int