Skip to content

Commit a1c5c3d

Browse files
Merge pull request #231792 from dargilco/dargilco/update-cts-sample
Properly handle error case in the ConversationTranscriber sample
2 parents 40be661 + 3bd2043 commit a1c5c3d

File tree

1 file changed

+8
-4
lines changed
  • articles/cognitive-services/Speech-Service/includes/how-to/remote-conversation/csharp

1 file changed

+8
-4
lines changed

articles/cognitive-services/Speech-Service/includes/how-to/remote-conversation/csharp/examples.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@ async Task CompleteContinuousRecognition(ConversationTranscriber recognizer, str
2222
{
2323
finishedTaskCompletionSource.TrySetResult(0);
2424
};
25-
string canceled = string.Empty;
2625

27-
recognizer.Canceled += (s, e) => {
28-
canceled = e.ErrorDetails;
26+
recognizer.Canceled += (s, e) =>
27+
{
28+
Console.WriteLine($"CANCELED: Reason={e.Reason}");
2929
if (e.Reason == CancellationReason.Error)
3030
{
31-
finishedTaskCompletionSource.TrySetResult(0);
31+
Console.WriteLine($"CANCELED: ErrorCode={e.ErrorCode}");
32+
Console.WriteLine($"CANCELED: ErrorDetails={e.ErrorDetails}");
33+
Console.WriteLine($"CANCELED: Did you update the subscription info?");
34+
throw new System.ApplicationException("${e.ErrorDetails}");
3235
}
36+
finishedTaskCompletionSource.TrySetResult(0);
3337
};
3438

3539
await recognizer.StartTranscribingAsync().ConfigureAwait(false);

0 commit comments

Comments
 (0)