diff options
author | Terry Tice <nufyoot@gmail.com> | 2013-11-28 12:22:35 -0500 |
---|---|---|
committer | Terry Tice <nufyoot@gmail.com> | 2013-11-28 12:22:35 -0500 |
commit | 70f18f85a5d97a7d6ef8a7863a75b09d953fe985 (patch) | |
tree | 46340dd7c023e6bb73d35ead82649b9fe41d75c4 /SendGrid/SendGridMail/Transport | |
parent | a408a6567a21dbdd59403b769143477c4dbea6c4 (diff) | |
download | sendgrid-csharp-70f18f85a5d97a7d6ef8a7863a75b09d953fe985.zip sendgrid-csharp-70f18f85a5d97a7d6ef8a7863a75b09d953fe985.tar.gz sendgrid-csharp-70f18f85a5d97a7d6ef8a7863a75b09d953fe985.tar.bz2 |
Make DeliverAsync awaitable so any errors that happen during delivery can be caught.
Diffstat (limited to 'SendGrid/SendGridMail/Transport')
-rw-r--r-- | SendGrid/SendGridMail/Transport/Web.cs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/SendGrid/SendGridMail/Transport/Web.cs b/SendGrid/SendGridMail/Transport/Web.cs index 49bceb7..0909e34 100644 --- a/SendGrid/SendGridMail/Transport/Web.cs +++ b/SendGrid/SendGridMail/Transport/Web.cs @@ -6,6 +6,7 @@ using System.Net; using System.Net.Http.Headers;
using System.Xml;
using System.Net.Http;
+using System.Threading.Tasks;
namespace SendGridMail.Transport
{
@@ -64,7 +65,7 @@ namespace SendGridMail.Transport /// Asynchronously delivers a message over SendGrid's Web interface
/// </summary>
/// <param name="message"></param>
- public async void DeliverAsync(ISendGrid message)
+ public async Task DeliverAsync(ISendGrid message)
{
var client = new HttpClient
{
@@ -75,7 +76,7 @@ namespace SendGridMail.Transport AttachFormParams(message, content);
AttachFiles(message, content);
var response = await client.PostAsync(Endpoint + ".xml", content);
- CheckForErrorsAsync(response);
+ await CheckForErrorsAsync(response);
}
#region Support Methods
@@ -162,7 +163,7 @@ namespace SendGridMail.Transport }
}
- private async void CheckForErrorsAsync(HttpResponseMessage response)
+ private async Task CheckForErrorsAsync(HttpResponseMessage response)
{
//transport error
if (response.StatusCode != HttpStatusCode.OK)
|