Skip to content

Commit bbafa6b

Browse files
Updating dotnet docs with RequestFailedException
1 parent a8d63b3 commit bbafa6b

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

articles/communication-services/quickstarts/email/includes/send-email-net.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,16 +193,15 @@ try
193193
}
194194
else
195195
{
196-
var error = statusMonitor.Error;
197196
Console.WriteLine($"Failed to send email.\n OperationId = {operationId}.\n Status = {emailSendStatus}.");
198-
Console.WriteLine($"Error Code = {error.Code}, Message = {error.Message}");
199197
return;
200198
}
201199
}
202-
catch (Exception ex)
200+
catch (RequestFailedException ex)
203201
{
204-
Console.WriteLine($"Error in sending email, {ex}");
205-
}
202+
/// OperationID is contained in the exception message and can be used for troubleshooting purposes
203+
Console.WriteLine($"Email send operation failed with error code: {ex.ErrorCode}, message: {ex.Message}");
204+
}
206205
```
207206

208207
### Getting email delivery status
@@ -276,9 +275,7 @@ try
276275
}
277276
else
278277
{
279-
var error = statusMonitor.Error;
280278
Console.WriteLine($"Failed to send email.\n OperationId = {operationId}.\n Status = {emailSendStatus}.");
281-
Console.WriteLine($"Error Code = {error.Code}, Message = {error.Message}");
282279
return;
283280
}
284281
}
@@ -287,9 +284,9 @@ try
287284
Console.WriteLine($"We have timed out while polling for email status");
288285
}
289286
}
290-
catch (Exception ex)
287+
catch (RequestFailedException ex)
291288
{
292-
Console.WriteLine($"Error in sending email, {ex}");
289+
Console.WriteLine($"Email send operation failed with error code: {ex.ErrorCode}, message: {ex.Message}");
293290
}
294291
```
295292

@@ -363,9 +360,9 @@ try
363360
return;
364361
}
365362
}
366-
catch (Exception ex)
363+
catch (RequestFailedException ex)
367364
{
368-
Console.WriteLine($"Error in sending email, {ex}");
365+
Console.WriteLine($"Email send operation failed with error code: {ex.ErrorCode}, message: {ex.Message}");
369366
}
370367

371368
```

0 commit comments

Comments
 (0)