Skip to content

Commit 3bd2043

Browse files
author
Darren Cohen
committed
Properly handle error case
1 parent 5930508 commit 3bd2043

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)