go-mail/mail

Expose wrapped errors returned by Send()

Closed this issue · 5 comments

ivy commented

Originally reported in go-gomail#102, the error details are lost in Send() due the use of fmt.Errorf. As mentioned in the original issue, we should allow smarter handling of errors by exposing the original error and index in a struct:

// A SendError represents the failed transmission of a Message and details the
// original error and index of the Message if it was part of a batch.
type SendError struct {
  // Index specifies the index of the Message, if it was part of a batch.
  Index uint

  // Cause specifies the error detailing the original cause of the failure.
  Cause error
}

func (err *SendError) Error() string {
	return fmt.Sprintf("gomail: could not send email %d: %v",
		err.Index, err.Cause)
}

I could possibly pick this up, I've wanted to improve the error handling for a while. For example if gomail rejects the address syntax it would be nicer to have a specific error that could be matched on rather than relying on a string match.

ivy commented

@lucianjon Yes! That would be wonderful.

Snag here is whether to KEEP alive, or cancel.

If missued then this is the same poblem on mail server connect..
eg latentcy of 400ms for conne

This means the write out to nginx is much faster though

@ivy Ping? Can you please leave feedback on @beeceej's pull request?

ivy commented

@sfllaw Thanks for the reminder! I had some time today to integrate #19. Let me know if there anything else I can help you with.