Skip to content

Commit

Permalink
update readme with Result.Throw methods
Browse files Browse the repository at this point in the history
  • Loading branch information
eskilgh committed Jan 16, 2024
1 parent 07ff5a7 commit 5d0e70a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,15 @@ else
// Handle error
}
```

Alternatively, if you prefer an exception based control flow, you can force the `Result` type to throw if the operation was not successful:

```csharp
Result result = await device.SetFramingMode(FramingMode.SpeakerFraming);
result.ThrowIfError();
```

```csharp
Result<FramingMode> result = await device.GetFramingMode(FramingMode.SpeakerFraming);
FramingMode currentFramingMode = result.GetValueOrThrow();
```

0 comments on commit 5d0e70a

Please sign in to comment.