mirror of
https://github.com/mjl-/mox.git
synced 2025-07-19 00:06:37 +03:00
check and log errors more often in deferred cleanup calls, and log remote-induced errors at lower priority
We normally check errors for all operations. But for some cleanup calls, eg "defer file.Close()", we didn't. Now we also check and log most of those. Partially because those errors can point to some mishandling or unexpected code paths (eg file unexpected already closed). And in part to make it easier to use "errcheck" to find the real missing error checks, there is too much noise now. The log.Check function can now be used unconditionally for checking and logging about errors. It adjusts the log level if the error is caused by a network connection being closed, or a context is canceled or its deadline reached, or a socket deadline is reached.
This commit is contained in:
@ -118,7 +118,9 @@ possibly making them potentially no longer readable by the previous version.
|
||||
return nil
|
||||
})
|
||||
checkf(err, path, "reading bolt database")
|
||||
bdb.Close()
|
||||
if err := bdb.Close(); err != nil {
|
||||
log.Printf("closing database file: %v", err)
|
||||
}
|
||||
|
||||
opts := bstore.Options{RegisterLogger: c.log.Logger}
|
||||
db, err := bstore.Open(ctxbg, path, &opts, types...)
|
||||
@ -126,7 +128,11 @@ possibly making them potentially no longer readable by the previous version.
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer db.Close()
|
||||
defer func() {
|
||||
if err := db.Close(); err != nil {
|
||||
log.Printf("closing database file: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
err = db.Read(ctxbg, func(tx *bstore.Tx) error {
|
||||
// Check bstore consistency, if it can export all records for all types. This is a
|
||||
|
Reference in New Issue
Block a user