Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Certain errors that bubble up from MailerMessageStore.SaveAsync are swallowed #218

Open
lachlann562 opened this issue Apr 26, 2024 · 0 comments

Comments

@lachlann562
Copy link

lachlann562 commented Apr 26, 2024

While implementing MailerMessageStore.SaveAsync, When i deployed the service to a server. All emails were failing. Eventually to diagnose the issue I cloned and built the project locally. The DataCommand.ExecuteAsync can swallow an exception if the ReadDotBlockAsync delegate returns an exception. In my case, due to an assembly issue it was raising System.MissingMethodException: Method not found. This is despite the problem command being wrapped in a try/catch in my code.

the current SmtpServer code does:

catch (Exception)
{
    await context.Pipe.Output.WriteReplyAsync(new SmtpResponse(SmtpReplyCode.TransactionFailed), cancellationToken).ConfigureAwait(false);
}

It should capture the exception and either log it somewhere (e.g. eventlog) or call an event or some other method so the caller can identify this exception occurred and decide how to handle it.

Example of my implementation:

public override async Task<SmtpResponse> SaveAsync(ISessionContext context, IMessageTransaction transaction, ReadOnlySequence<byte> buffer, CancellationToken cancellationToken)
{
   try {
      // call  class.method in problem assembly
   } catch (Exception ex) {
     // do something with exception
     // this is NOT triggered, it is caught in the DataCommand.ExecuteAsync
   }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant