consistently use log.Check for logging errors that "should not happen", don't influence application flow

sooner or later, someone will notice one of these messages, which will lead us
to a bug.
This commit is contained in:
Mechiel Lukkien
2023-02-16 13:22:00 +01:00
parent ef8e5fa1a8
commit 5c33640aea
30 changed files with 366 additions and 246 deletions

View File

@ -189,9 +189,9 @@ func adminHandle(w http.ResponseWriter, r *http.Request) {
f, err := os.Open("http/admin.html")
if err == nil {
defer f.Close()
io.Copy(w, f)
_, _ = io.Copy(w, f)
} else {
w.Write(adminHTML)
_, _ = w.Write(adminHTML)
}
return
}
@ -549,8 +549,8 @@ func checkDomain(ctx context.Context, resolver dns.Resolver, dialer *net.Dialer,
end := time.Now().Add(10 * time.Second)
cctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
conn.SetReadDeadline(end)
conn.SetWriteDeadline(end)
err = conn.SetDeadline(end)
xlog.WithContext(ctx).Check(err, "setting deadline")
br := bufio.NewReader(conn)
_, err = br.ReadString('\n')
@ -1447,7 +1447,10 @@ func (Admin) SetPassword(ctx context.Context, accountName, password string) {
}
acc, err := store.OpenAccount(accountName)
xcheckf(ctx, err, "open account")
defer acc.Close()
defer func() {
err := acc.Close()
xlog.Check(err, "closing account")
}()
err = acc.SetPassword(password)
xcheckf(ctx, err, "setting password")
}