GODT-2296: Log error rather than fail if cannot get parent ID

This commit is contained in:
James Houlahan
2023-01-24 14:29:35 +01:00
parent e8a778feca
commit 1bfabf9a83

View File

@ -28,6 +28,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/ProtonMail/gluon/reporter"
"github.com/ProtonMail/gluon/rfc822" "github.com/ProtonMail/gluon/rfc822"
"github.com/ProtonMail/go-proton-api" "github.com/ProtonMail/go-proton-api"
"github.com/ProtonMail/go-rfc5322" "github.com/ProtonMail/go-rfc5322"
@ -142,6 +143,7 @@ func (user *User) sendMail(authID string, from string, to []string, r io.Reader)
sent, err := sendWithKey( sent, err := sendWithKey(
ctx, ctx,
user.client, user.client,
user.reporter,
authID, authID,
user.vault.AddressMode(), user.vault.AddressMode(),
settings, settings,
@ -165,6 +167,7 @@ func (user *User) sendMail(authID string, from string, to []string, r io.Reader)
func sendWithKey( //nolint:funlen func sendWithKey( //nolint:funlen
ctx context.Context, ctx context.Context,
client *proton.Client, client *proton.Client,
sentry reporter.Reporter,
authAddrID string, authAddrID string,
addrMode vault.AddressMode, addrMode vault.AddressMode,
settings proton.MailSettings, settings proton.MailSettings,
@ -180,7 +183,14 @@ func sendWithKey( //nolint:funlen
} }
parentID, err := getParentID(ctx, client, authAddrID, addrMode, references) parentID, err := getParentID(ctx, client, authAddrID, addrMode, references)
if err != nil { if err != nil {
return proton.Message{}, fmt.Errorf("failed to get parent ID: %w", err) if err := sentry.ReportMessageWithContext("Failed to get parent ID", reporter.Context{
"error": err,
"references": message.References,
}); err != nil {
logrus.WithError(err).Error("Failed to report error")
}
logrus.WithError(err).Warn("Failed to get parent ID")
} }
var decBody string var decBody string