1
0
mirror of https://github.com/nikoksr/notify.git synced 2025-11-06 09:09:09 +02:00

refactor(sendgrid): fix faulty error return

This commit is contained in:
Niko Köser
2021-02-23 00:03:21 +01:00
parent 19d5488113
commit 880563e250

View File

@@ -54,20 +54,19 @@ func (s SendGrid) Send(ctx context.Context, subject, message string) error {
mailMessage.AddContent(content)
mailMessage.SetFrom(from)
var err error
select {
case <-ctx.Done():
return ctx.Err()
default:
resp, err := s.client.Send(mailMessage)
if err != nil {
err = errors.Wrap(err, "failed to send mail using SendGrid service")
return errors.Wrap(err, "failed to send mail using SendGrid service")
}
if resp.StatusCode != http.StatusAccepted {
err = errors.New("the SendGrid endpoint did not accept the message")
return errors.New("the SendGrid endpoint did not accept the message")
}
}
return err
return nil
}