Skip to content

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

@lachlann562

Description

@lachlann562

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
   }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions