2

Can anyone show me how to handle exceptions when using the .NET SDK for AWS SES?

The implementation of IAsyncResult that is returned has the Exception on it, but its internal.

Is there an alternative method for accessing this, or do I need to reflect it :(

amazonSimpleEmailServiceClient.BeginSendEmail(sendEmailRequest, ar => {
    var result = ar as AsyncResult;
    // result has .Exception, but its internal :(
}, null);

Thanks

Charles
  • 50,943
  • 13
  • 104
  • 142
Andrew Bullock
  • 36,616
  • 34
  • 155
  • 231

1 Answers1

1

The standard approach with Begin*/End* methods in the .NET AWS SDK (and .NET overall, as discussed in a bit of detail here) is to call the corresponding End* method.

amazonSimpleEmailServiceClient.BeginSendEmail(sendEmailRequest, ar =>
{
    try
    {
        amazonSimpleEmailServiceClient.EndSendEmail(ar);
    }
    catch (Exception e)
    {
        Console.WriteLine(e);
    }
}, null);
Community
  • 1
  • 1
Pavel Safronov
  • 1,286
  • 10
  • 11