Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed Nov 11, 2023
1 parent bf5a3a8 commit 9006392
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,29 +325,45 @@ var cmd = Cli.Wrap("git")
.WithValidation(CommandResultValidation.None);
```

If you want to throw a custom exception when the process exits with a non-zero exit code, don't disable the result validation, but instead catch the `CommandExecutionException` and rethrow it as part of your own exception.
This way you can preserve additional information provided by the original exception, while extending it with your own context:

```csharp
try
{
await Cli.Wrap("git").ExecuteAsync();
}
catch (CommandExecutionException ex)
{
// Re-throw the original exception to preserve additional information
// about the command that failed (exit code, arguments, etc.).
throw new MyException("Failed to run the git command-line tool.", ex);
}
```

#### `WithStandardInputPipe(...)`

Sets the pipe source that will be used for the standard _input_ stream of the process.

**Default**: `PipeSource.Null`.

_Read more about this method in the [piping section](#piping)._
Read more about this method in the [piping section](#piping).

#### `WithStandardOutputPipe(...)`

Sets the pipe target that will be used for the standard _output_ stream of the process.

**Default**: `PipeTarget.Null`.

_Read more about this method in the [piping section](#piping)._
Read more about this method in the [piping section](#piping).

#### `WithStandardErrorPipe(...)`

Sets the pipe target that will be used for the standard _error_ stream of the process.

**Default**: `PipeTarget.Null`.

_Read more about this method in the [piping section](#piping)._
Read more about this method in the [piping section](#piping).

### Piping

Expand Down

0 comments on commit 9006392

Please sign in to comment.