Home > OS >  SendGrid works, but still throws exception not catchable in catch() block
SendGrid works, but still throws exception not catchable in catch() block

Time:01-17

Note: To the moderator that incorrectly closed this question, it's completely different from the generic enter image description here

So it is working and sending the email, but why the heavy crash? What am I doing wrong?

CodePudding user response:

The method is awaitable:

public async Task<string> SendEmailSendGrid(...

Yet, the caller is not awaiting the result:

var result = utils.SendEmailSendGrid(decodedEmail, ...

Either await the result:

var result = await utils.SendEmailSendGrid(decodedEmail, ...

Or, if the invoking method is not an async method:

var result = utils.SendEmailSendGrid(decodedEmail, ...).GetAwaiter().GetResult();

Visual Studio is not breaking inside of your try/catch b/c the exception is in the .NET framework by not awaiting the result. You should be able to resolve that by enabling "just my code" in the visual studio debugger settings (IIRC).

  •  Tags:  
  • Related