You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some commands return non-zero exit codes when they succeed. For example, Robocopy:
An Exit Code of 0-7 is success and any value >= 8 indicates that there was at least one failure during the copy operation.
When running such a command, the default exit code handling in SimpleExec may throw an exception when the command succeeds. Custom exit code handling is required for these scenarios.
Description
Run, RunAsync, Read, and ReadAsync have a new optional parameter: Func<int, bool> handleExit. The supplied delegate argument should return true to indicate that it handled the exit code, and that the default exit code handling in SimpleExec should be suppressed, and false otherwise.
Breaking, because handleExitCode was added as an optional parameter beforecancellationToken in RunAsync and ReadAsync.
Also deprecates NonZeroExitCodeException in favour of ExitCodeException, since the name of the former doesn't make sense when an argument is supplied to handleExitCode.
Alternatives
Catch and swallow the exception in consuming code when the exit code indicates success.
Additional context
Replaces #298. Thanks to @nixtar for raising that issue.
Use case(s)
Some commands return non-zero exit codes when they succeed. For example, Robocopy:
When running such a command, the default exit code handling in SimpleExec may throw an exception when the command succeeds. Custom exit code handling is required for these scenarios.
Description
Run
,RunAsync
,Read
, andReadAsync
have a new optional parameter:Func<int, bool> handleExit
. The supplied delegate argument should returntrue
to indicate that it handled the exit code, and that the default exit code handling in SimpleExec should be suppressed, andfalse
otherwise.For example:
Breaking, because
handleExitCode
was added as an optional parameter beforecancellationToken
inRunAsync
andReadAsync
.Also deprecates
NonZeroExitCodeException
in favour ofExitCodeException
, since the name of the former doesn't make sense when an argument is supplied tohandleExitCode
.Alternatives
Catch and swallow the exception in consuming code when the exit code indicates success.
Additional context
Replaces #298. Thanks to @nixtar for raising that issue.
Depends on #311.
The text was updated successfully, but these errors were encountered: