in store/, change functions from calling panic to returning errors

this is a library package, errors should be explicit. callers had to be careful
when calling these "X" functions. now it's explicit.
This commit is contained in:
Mechiel Lukkien
2023-04-20 14:16:56 +02:00
parent 936a0d5afe
commit 08eb1a5472
9 changed files with 173 additions and 165 deletions

View File

@ -2,6 +2,7 @@ package smtpserver
import (
"context"
"fmt"
"net"
"os"
"time"
@ -172,7 +173,10 @@ func analyze(ctx context.Context, log *mlog.Log, resolver dns.Resolver, d delive
if rs != nil {
mailbox = rs.Mailbox
}
mb := d.acc.MailboxFindX(tx, mailbox)
mb, err := d.acc.MailboxFind(tx, mailbox)
if err != nil {
return fmt.Errorf("finding destination mailbox: %w", err)
}
if mb != nil {
// We want to deliver to mb.ID, but this message may be rejected and sent to the
// Rejects mailbox instead, which MailboxID overwritten. Record the ID in
@ -187,7 +191,6 @@ func analyze(ctx context.Context, log *mlog.Log, resolver dns.Resolver, d delive
log.Debug("mailbox not found in database", mlog.Field("mailbox", mailbox))
}
var err error
isjunk, conclusive, method, err = reputation(tx, log, d.m)
reason = string(method)
return err