logging: substitute %w for %v

Subsitute the format specifier %w for %v in the logging facility. The
logging functions use a fmt.Sprintf call behind the scene which does not
recognize %w. %w should be used in fmt.Errorf when you want to wrap
errors. Hence, the log entries that use %w are improperly formatted like
this:

ERROR 2022/10/02 09:13:57.724529 worker.go:439: could not get message
info %!w(*fmt.wrapError=&{could not get structure: [snip] })
      ^

Links: https://go.dev/blog/go1.13-errors
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
This commit is contained in:
Koni Marti 2022-10-02 11:36:05 +02:00 committed by Robin Jarry
parent 020279108c
commit dc299cc8ad
9 changed files with 66 additions and 66 deletions

View file

@ -143,7 +143,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
defer tmpFile.Close() defer tmpFile.Close()
_, err = io.Copy(tmpFile, fm.Content.Reader) _, err = io.Copy(tmpFile, fm.Content.Reader)
if err != nil { if err != nil {
logging.Warnf("failed to write to tmpfile: %w", err) logging.Warnf("failed to write to tmpfile: %v", err)
return return
} }
composer, err := addTab() composer, err := addTab()

View file

@ -98,7 +98,7 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error {
defer pipe.Close() defer pipe.Close()
_, err := io.Copy(pipe, reader) _, err := io.Copy(pipe, reader)
if err != nil { if err != nil {
logging.Errorf("failed to send data to pipe: %w", err) logging.Errorf("failed to send data to pipe: %v", err)
} }
}() }()
err = ecmd.Run() err = ecmd.Run()

View file

@ -433,7 +433,7 @@ func (store *MessageStore) SelectedThread() *types.Thread {
return nil return nil
}) })
if err != nil { if err != nil {
logging.Errorf("SelectedThread failed: %w", err) logging.Errorf("SelectedThread failed: %v", err)
} }
if found { if found {
break break

View file

@ -667,7 +667,7 @@ func (pv *PartViewer) attemptCopy() {
// if it's binary we have to rely on the filter to be sane // if it's binary we have to rely on the filter to be sane
_, err := io.Copy(pv.sink, pv.source) _, err := io.Copy(pv.sink, pv.source)
if err != nil { if err != nil {
logging.Warnf("failed to copy: %w", err) logging.Warnf("failed to copy: %v", err)
} }
} }
pv.sink.Close() pv.sink.Close()

View file

@ -84,7 +84,7 @@ func (term *Terminal) Draw(ctx *ui.Context) {
term.vterm.Watch(term) term.vterm.Watch(term)
attr := &syscall.SysProcAttr{Setsid: true, Setctty: true, Ctty: 1} attr := &syscall.SysProcAttr{Setsid: true, Setctty: true, Ctty: 1}
if err := term.vterm.StartWithAttrs(term.cmd, attr); err != nil { if err := term.vterm.StartWithAttrs(term.cmd, attr); err != nil {
logging.Errorf("error running terminal: %w", err) logging.Errorf("error running terminal: %v", err)
term.Close(err) term.Close(err)
return return
} }

View file

@ -111,7 +111,7 @@ func (w *Worker) handleFSEvent(ev fsnotify.Event) {
} }
err := w.c.SyncNewMail(*w.selected) err := w.c.SyncNewMail(*w.selected)
if err != nil { if err != nil {
logging.Errorf("could not move new to cur : %w", err) logging.Errorf("could not move new to cur : %v", err)
return return
} }
@ -190,18 +190,18 @@ func (w *Worker) getDirectoryInfo(name string) *models.DirectoryInfo {
for _, v := range files { for _, v := range files {
key, flags, err := splitMaildirFile(v) key, flags, err := splitMaildirFile(v)
if err != nil { if err != nil {
logging.Errorf("%q: error parsing flags (%q): %w", v, key, err) logging.Errorf("%q: error parsing flags (%q): %v", v, key, err)
continue continue
} }
keyFlags[key] = flags keyFlags[key] = flags
} }
} else { } else {
logging.Infof("disabled flags cache: %q: %w", dir, err) logging.Infof("disabled flags cache: %q: %v", dir, err)
} }
uids, err := w.c.UIDs(dir) uids, err := w.c.UIDs(dir)
if err != nil { if err != nil {
logging.Errorf("could not get uids: %w", err) logging.Errorf("could not get uids: %v", err)
return dirInfo return dirInfo
} }
@ -209,7 +209,7 @@ func (w *Worker) getDirectoryInfo(name string) *models.DirectoryInfo {
for _, uid := range uids { for _, uid := range uids {
message, err := w.c.Message(dir, uid) message, err := w.c.Message(dir, uid)
if err != nil { if err != nil {
logging.Errorf("could not get message: %w", err) logging.Errorf("could not get message: %v", err)
continue continue
} }
var flags []maildir.Flag var flags []maildir.Flag
@ -220,14 +220,14 @@ func (w *Worker) getDirectoryInfo(name string) *models.DirectoryInfo {
logging.Debugf("message (key=%q uid=%d) not found in map cache", message.key, message.uid) logging.Debugf("message (key=%q uid=%d) not found in map cache", message.key, message.uid)
flags, err = message.Flags() flags, err = message.Flags()
if err != nil { if err != nil {
logging.Errorf("could not get flags: %w", err) logging.Errorf("could not get flags: %v", err)
continue continue
} }
} }
} else { } else {
flags, err = message.Flags() flags, err = message.Flags()
if err != nil { if err != nil {
logging.Errorf("could not get flags: %w", err) logging.Errorf("could not get flags: %v", err)
continue continue
} }
} }
@ -294,7 +294,7 @@ func (w *Worker) handleMessage(msg types.WorkerMessage) error {
func (w *Worker) handleConfigure(msg *types.Configure) error { func (w *Worker) handleConfigure(msg *types.Configure) error {
u, err := url.Parse(msg.Config.Source) u, err := url.Parse(msg.Config.Source)
if err != nil { if err != nil {
logging.Errorf("error configuring maildir worker: %w", err) logging.Errorf("error configuring maildir worker: %v", err)
return err return err
} }
dir := u.Path dir := u.Path
@ -331,7 +331,7 @@ func (w *Worker) handleListDirectories(msg *types.ListDirectories) error {
} }
dirs, err := w.c.ListFolders() dirs, err := w.c.ListFolders()
if err != nil { if err != nil {
logging.Errorf("failed listing directories: %w", err) logging.Errorf("failed listing directories: %v", err)
return err return err
} }
for _, name := range dirs { for _, name := range dirs {
@ -414,13 +414,13 @@ func (w *Worker) handleFetchDirectoryContents(
} else { } else {
uids, err = w.c.UIDs(*w.selected) uids, err = w.c.UIDs(*w.selected)
if err != nil { if err != nil {
logging.Errorf("failed scanning uids: %w", err) logging.Errorf("failed scanning uids: %v", err)
return err return err
} }
} }
sortedUids, err := w.sort(uids, msg.SortCriteria) sortedUids, err := w.sort(uids, msg.SortCriteria)
if err != nil { if err != nil {
logging.Errorf("failed sorting directory: %w", err) logging.Errorf("failed sorting directory: %v", err)
return err return err
} }
w.currentSortCriteria = msg.SortCriteria w.currentSortCriteria = msg.SortCriteria
@ -439,14 +439,14 @@ func (w *Worker) sort(uids []uint32, criteria []*types.SortCriterion) ([]uint32,
for _, uid := range uids { for _, uid := range uids {
info, err := w.msgInfoFromUid(uid) info, err := w.msgInfoFromUid(uid)
if err != nil { if err != nil {
logging.Errorf("could not get message info: %w", err) logging.Errorf("could not get message info: %v", err)
continue continue
} }
msgInfos = append(msgInfos, info) msgInfos = append(msgInfos, info)
} }
sortedUids, err := lib.Sort(msgInfos, criteria) sortedUids, err := lib.Sort(msgInfos, criteria)
if err != nil { if err != nil {
logging.Errorf("could not sort the messages: %w", err) logging.Errorf("could not sort the messages: %v", err)
return nil, err return nil, err
} }
return sortedUids, nil return sortedUids, nil
@ -455,7 +455,7 @@ func (w *Worker) sort(uids []uint32, criteria []*types.SortCriterion) ([]uint32,
func (w *Worker) handleCreateDirectory(msg *types.CreateDirectory) error { func (w *Worker) handleCreateDirectory(msg *types.CreateDirectory) error {
dir := w.c.Dir(msg.Directory) dir := w.c.Dir(msg.Directory)
if err := dir.Init(); err != nil { if err := dir.Init(); err != nil {
logging.Errorf("could not create directory %s: %w", logging.Errorf("could not create directory %s: %v",
msg.Directory, err) msg.Directory, err)
return err return err
} }
@ -465,7 +465,7 @@ func (w *Worker) handleCreateDirectory(msg *types.CreateDirectory) error {
func (w *Worker) handleRemoveDirectory(msg *types.RemoveDirectory) error { func (w *Worker) handleRemoveDirectory(msg *types.RemoveDirectory) error {
dir := w.c.Dir(msg.Directory) dir := w.c.Dir(msg.Directory)
if err := os.RemoveAll(string(dir)); err != nil { if err := os.RemoveAll(string(dir)); err != nil {
logging.Errorf("could not remove directory %s: %w", logging.Errorf("could not remove directory %s: %v",
msg.Directory, err) msg.Directory, err)
return err return err
} }
@ -478,7 +478,7 @@ func (w *Worker) handleFetchMessageHeaders(
for _, uid := range msg.Uids { for _, uid := range msg.Uids {
info, err := w.msgInfoFromUid(uid) info, err := w.msgInfoFromUid(uid)
if err != nil { if err != nil {
logging.Errorf("could not get message info: %w", err) logging.Errorf("could not get message info: %v", err)
w.worker.PostMessageInfoError(msg, uid, err) w.worker.PostMessageInfoError(msg, uid, err)
continue continue
} }
@ -497,7 +497,7 @@ func (w *Worker) handleFetchMessageBodyPart(
// get reader // get reader
m, err := w.c.Message(*w.selected, msg.Uid) m, err := w.c.Message(*w.selected, msg.Uid)
if err != nil { if err != nil {
logging.Errorf("could not get message %d: %w", msg.Uid, err) logging.Errorf("could not get message %d: %v", msg.Uid, err)
return err return err
} }
r, err := m.NewBodyPartReader(msg.Part) r, err := m.NewBodyPartReader(msg.Part)
@ -522,12 +522,12 @@ func (w *Worker) handleFetchFullMessages(msg *types.FetchFullMessages) error {
for _, uid := range msg.Uids { for _, uid := range msg.Uids {
m, err := w.c.Message(*w.selected, uid) m, err := w.c.Message(*w.selected, uid)
if err != nil { if err != nil {
logging.Errorf("could not get message %d: %w", uid, err) logging.Errorf("could not get message %d: %v", uid, err)
return err return err
} }
r, err := m.NewReader() r, err := m.NewReader()
if err != nil { if err != nil {
logging.Errorf("could not get message reader: %w", err) logging.Errorf("could not get message reader: %v", err)
return err return err
} }
defer r.Close() defer r.Close()
@ -558,7 +558,7 @@ func (w *Worker) handleDeleteMessages(msg *types.DeleteMessages) error {
}, nil) }, nil)
} }
if err != nil { if err != nil {
logging.Errorf("failed removing messages: %w", err) logging.Errorf("failed removing messages: %v", err)
return err return err
} }
return nil return nil
@ -568,18 +568,18 @@ func (w *Worker) handleAnsweredMessages(msg *types.AnsweredMessages) error {
for _, uid := range msg.Uids { for _, uid := range msg.Uids {
m, err := w.c.Message(*w.selected, uid) m, err := w.c.Message(*w.selected, uid)
if err != nil { if err != nil {
logging.Errorf("could not get message: %w", err) logging.Errorf("could not get message: %v", err)
w.err(msg, err) w.err(msg, err)
continue continue
} }
if err := m.MarkReplied(msg.Answered); err != nil { if err := m.MarkReplied(msg.Answered); err != nil {
logging.Errorf("could not mark message as answered: %w", err) logging.Errorf("could not mark message as answered: %v", err)
w.err(msg, err) w.err(msg, err)
continue continue
} }
info, err := m.MessageInfo() info, err := m.MessageInfo()
if err != nil { if err != nil {
logging.Errorf("could not get message info: %w", err) logging.Errorf("could not get message info: %v", err)
w.err(msg, err) w.err(msg, err)
continue continue
} }
@ -600,19 +600,19 @@ func (w *Worker) handleFlagMessages(msg *types.FlagMessages) error {
for _, uid := range msg.Uids { for _, uid := range msg.Uids {
m, err := w.c.Message(*w.selected, uid) m, err := w.c.Message(*w.selected, uid)
if err != nil { if err != nil {
logging.Errorf("could not get message: %w", err) logging.Errorf("could not get message: %v", err)
w.err(msg, err) w.err(msg, err)
continue continue
} }
flag := flagToMaildir[msg.Flag] flag := flagToMaildir[msg.Flag]
if err := m.SetOneFlag(flag, msg.Enable); err != nil { if err := m.SetOneFlag(flag, msg.Enable); err != nil {
logging.Errorf("could change flag %v to %v on message: %w", flag, msg.Enable, err) logging.Errorf("could change flag %v to %v on message: %v", flag, msg.Enable, err)
w.err(msg, err) w.err(msg, err)
continue continue
} }
info, err := m.MessageInfo() info, err := m.MessageInfo()
if err != nil { if err != nil {
logging.Errorf("could not get message info: %w", err) logging.Errorf("could not get message info: %v", err)
w.err(msg, err) w.err(msg, err)
continue continue
} }
@ -663,12 +663,12 @@ func (w *Worker) handleAppendMessage(msg *types.AppendMessage) error {
dest := w.c.Dir(msg.Destination) dest := w.c.Dir(msg.Destination)
_, writer, err := dest.Create(translateFlags(msg.Flags)) _, writer, err := dest.Create(translateFlags(msg.Flags))
if err != nil { if err != nil {
logging.Errorf("could not create message at %s: %w", msg.Destination, err) logging.Errorf("could not create message at %s: %v", msg.Destination, err)
return err return err
} }
defer writer.Close() defer writer.Close()
if _, err := io.Copy(writer, msg.Reader); err != nil { if _, err := io.Copy(writer, msg.Reader); err != nil {
logging.Errorf("could not write message to destination: %w", err) logging.Errorf("could not write message to destination: %v", err)
return err return err
} }
w.worker.PostMessage(&types.Done{ w.worker.PostMessage(&types.Done{

View file

@ -167,7 +167,7 @@ func (w *mboxWorker) handleMessage(msg types.WorkerMessage) error {
case *types.FetchMessageBodyPart: case *types.FetchMessageBodyPart:
m, err := w.folder.Message(msg.Uid) m, err := w.folder.Message(msg.Uid)
if err != nil { if err != nil {
logging.Errorf("could not get message %d: %w", msg.Uid, err) logging.Errorf("could not get message %d: %v", msg.Uid, err)
reterr = err reterr = err
break break
} }
@ -205,18 +205,18 @@ func (w *mboxWorker) handleMessage(msg types.WorkerMessage) error {
for _, uid := range msg.Uids { for _, uid := range msg.Uids {
m, err := w.folder.Message(uid) m, err := w.folder.Message(uid)
if err != nil { if err != nil {
logging.Errorf("could not get message for uid %d: %w", uid, err) logging.Errorf("could not get message for uid %d: %v", uid, err)
continue continue
} }
r, err := m.NewReader() r, err := m.NewReader()
if err != nil { if err != nil {
logging.Errorf("could not get message reader: %w", err) logging.Errorf("could not get message reader: %v", err)
continue continue
} }
defer r.Close() defer r.Close()
b, err := io.ReadAll(r) b, err := io.ReadAll(r)
if err != nil { if err != nil {
logging.Errorf("could not get message reader: %w", err) logging.Errorf("could not get message reader: %v", err)
continue continue
} }
w.worker.PostMessage(&types.FullMessage{ w.worker.PostMessage(&types.FullMessage{
@ -251,16 +251,16 @@ func (w *mboxWorker) handleMessage(msg types.WorkerMessage) error {
for _, uid := range msg.Uids { for _, uid := range msg.Uids {
m, err := w.folder.Message(uid) m, err := w.folder.Message(uid)
if err != nil { if err != nil {
logging.Errorf("could not get message: %w", err) logging.Errorf("could not get message: %v", err)
continue continue
} }
if err := m.(*message).SetFlag(msg.Flag, msg.Enable); err != nil { if err := m.(*message).SetFlag(msg.Flag, msg.Enable); err != nil {
logging.Errorf("could change flag %v to %t on message: %w", msg.Flag, msg.Enable, err) logging.Errorf("could change flag %v to %t on message: %v", msg.Flag, msg.Enable, err)
continue continue
} }
info, err := lib.MessageInfo(m) info, err := lib.MessageInfo(m)
if err != nil { if err != nil {
logging.Errorf("could not get message info: %w", err) logging.Errorf("could not get message info: %v", err)
continue continue
} }
@ -397,12 +397,12 @@ func sortUids(folder *container, uids []uint32,
for _, uid := range uids { for _, uid := range uids {
m, err := folder.Message(uid) m, err := folder.Message(uid)
if err != nil { if err != nil {
logging.Errorf("could not get message %w", err) logging.Errorf("could not get message %v", err)
continue continue
} }
info, err := lib.MessageInfo(m) info, err := lib.MessageInfo(m)
if err != nil { if err != nil {
logging.Errorf("could not get message info %w", err) logging.Errorf("could not get message info %v", err)
continue continue
} }
infos = append(infos, info) infos = append(infos, info)

View file

@ -66,18 +66,18 @@ func (w *worker) Run() {
w.w.PostMessage(&types.Unsupported{ w.w.PostMessage(&types.Unsupported{
Message: types.RespondTo(msg), Message: types.RespondTo(msg),
}, nil) }, nil)
logging.Errorf("ProcessAction(%T) unsupported: %w", msg, err) logging.Errorf("ProcessAction(%T) unsupported: %v", msg, err)
} else if err != nil { } else if err != nil {
w.w.PostMessage(&types.Error{ w.w.PostMessage(&types.Error{
Message: types.RespondTo(msg), Message: types.RespondTo(msg),
Error: err, Error: err,
}, nil) }, nil)
logging.Errorf("ProcessAction(%T) failure: %w", msg, err) logging.Errorf("ProcessAction(%T) failure: %v", msg, err)
} }
case nmEvent := <-w.nmEvents: case nmEvent := <-w.nmEvents:
err := w.handleNotmuchEvent(nmEvent) err := w.handleNotmuchEvent(nmEvent)
if err != nil { if err != nil {
logging.Errorf("notmuch event failure: %w", err) logging.Errorf("notmuch event failure: %v", err)
} }
} }
} }
@ -163,7 +163,7 @@ func (w *worker) handleConfigure(msg *types.Configure) error {
u, err := url.Parse(msg.Config.Source) u, err := url.Parse(msg.Config.Source)
if err != nil { if err != nil {
logging.Errorf("error configuring notmuch worker: %w", err) logging.Errorf("error configuring notmuch worker: %v", err)
return err return err
} }
home, err := homedir.Expand(u.Hostname()) home, err := homedir.Expand(u.Hostname())
@ -318,13 +318,13 @@ func (w *worker) handleFetchMessageHeaders(
for _, uid := range msg.Uids { for _, uid := range msg.Uids {
m, err := w.msgFromUid(uid) m, err := w.msgFromUid(uid)
if err != nil { if err != nil {
logging.Errorf("could not get message: %w", err) logging.Errorf("could not get message: %v", err)
w.w.PostMessageInfoError(msg, uid, err) w.w.PostMessageInfoError(msg, uid, err)
continue continue
} }
err = w.emitMessageInfo(m, msg) err = w.emitMessageInfo(m, msg)
if err != nil { if err != nil {
logging.Errorf("could not emit message info: %w", err) logging.Errorf("could not emit message info: %v", err)
w.w.PostMessageInfoError(msg, uid, err) w.w.PostMessageInfoError(msg, uid, err)
continue continue
} }
@ -365,7 +365,7 @@ func (w *worker) handleFetchMessageBodyPart(
) error { ) error {
m, err := w.msgFromUid(msg.Uid) m, err := w.msgFromUid(msg.Uid)
if err != nil { if err != nil {
logging.Errorf("could not get message %d: %w", msg.Uid, err) logging.Errorf("could not get message %d: %v", msg.Uid, err)
return err return err
} }
r, err := m.NewBodyPartReader(msg.Part) r, err := m.NewBodyPartReader(msg.Part)
@ -391,12 +391,12 @@ func (w *worker) handleFetchFullMessages(msg *types.FetchFullMessages) error {
for _, uid := range msg.Uids { for _, uid := range msg.Uids {
m, err := w.msgFromUid(uid) m, err := w.msgFromUid(uid)
if err != nil { if err != nil {
logging.Errorf("could not get message %d: %w", uid, err) logging.Errorf("could not get message %d: %v", uid, err)
return err return err
} }
r, err := m.NewReader() r, err := m.NewReader()
if err != nil { if err != nil {
logging.Errorf("could not get message reader: %w", err) logging.Errorf("could not get message reader: %v", err)
return err return err
} }
defer r.Close() defer r.Close()
@ -420,24 +420,24 @@ func (w *worker) handleAnsweredMessages(msg *types.AnsweredMessages) error {
for _, uid := range msg.Uids { for _, uid := range msg.Uids {
m, err := w.msgFromUid(uid) m, err := w.msgFromUid(uid)
if err != nil { if err != nil {
logging.Errorf("could not get message: %w", err) logging.Errorf("could not get message: %v", err)
w.err(msg, err) w.err(msg, err)
continue continue
} }
if err := m.MarkAnswered(msg.Answered); err != nil { if err := m.MarkAnswered(msg.Answered); err != nil {
logging.Errorf("could not mark message as answered: %w", err) logging.Errorf("could not mark message as answered: %v", err)
w.err(msg, err) w.err(msg, err)
continue continue
} }
err = w.emitMessageInfo(m, msg) err = w.emitMessageInfo(m, msg)
if err != nil { if err != nil {
logging.Errorf("could not emit message info: %w", err) logging.Errorf("could not emit message info: %v", err)
w.err(msg, err) w.err(msg, err)
continue continue
} }
} }
if err := w.emitDirectoryInfo(w.currentQueryName); err != nil { if err := w.emitDirectoryInfo(w.currentQueryName); err != nil {
logging.Errorf("could not emit directory info: %w", err) logging.Errorf("could not emit directory info: %v", err)
} }
w.done(msg) w.done(msg)
return nil return nil
@ -447,24 +447,24 @@ func (w *worker) handleFlagMessages(msg *types.FlagMessages) error {
for _, uid := range msg.Uids { for _, uid := range msg.Uids {
m, err := w.msgFromUid(uid) m, err := w.msgFromUid(uid)
if err != nil { if err != nil {
logging.Errorf("could not get message: %w", err) logging.Errorf("could not get message: %v", err)
w.err(msg, err) w.err(msg, err)
continue continue
} }
if err := m.SetFlag(msg.Flag, msg.Enable); err != nil { if err := m.SetFlag(msg.Flag, msg.Enable); err != nil {
logging.Errorf("could not set flag %v as %t for message: %w", msg.Flag, msg.Enable, err) logging.Errorf("could not set flag %v as %t for message: %v", msg.Flag, msg.Enable, err)
w.err(msg, err) w.err(msg, err)
continue continue
} }
err = w.emitMessageInfo(m, msg) err = w.emitMessageInfo(m, msg)
if err != nil { if err != nil {
logging.Errorf("could not emit message info: %w", err) logging.Errorf("could not emit message info: %v", err)
w.err(msg, err) w.err(msg, err)
continue continue
} }
} }
if err := w.emitDirectoryInfo(w.currentQueryName); err != nil { if err := w.emitDirectoryInfo(w.currentQueryName); err != nil {
logging.Errorf("could not emit directory info: %w", err) logging.Errorf("could not emit directory info: %v", err)
} }
w.done(msg) w.done(msg)
return nil return nil
@ -513,7 +513,7 @@ func (w *worker) handleModifyLabels(msg *types.ModifyLabels) error {
// and update the list of possible tags // and update the list of possible tags
w.emitLabelList() w.emitLabelList()
if err = w.emitDirectoryInfo(w.currentQueryName); err != nil { if err = w.emitDirectoryInfo(w.currentQueryName); err != nil {
logging.Errorf("could not emit directory info: %w", err) logging.Errorf("could not emit directory info: %v", err)
} }
w.done(msg) w.done(msg)
return nil return nil
@ -581,7 +581,7 @@ func (w *worker) emitDirectoryContents(parent types.WorkerMessage) error {
} }
sortedUids, err := w.sort(uids, w.currentSortCriteria) sortedUids, err := w.sort(uids, w.currentSortCriteria)
if err != nil { if err != nil {
logging.Errorf("error sorting directory: %w", err) logging.Errorf("error sorting directory: %v", err)
return err return err
} }
w.w.PostMessage(&types.DirectoryContents{ w.w.PostMessage(&types.DirectoryContents{
@ -626,7 +626,7 @@ func (w *worker) emitMessageInfo(m *Message,
func (w *worker) emitLabelList() { func (w *worker) emitLabelList() {
tags, err := w.db.ListTags() tags, err := w.db.ListTags()
if err != nil { if err != nil {
logging.Errorf("could not load tags: %w", err) logging.Errorf("could not load tags: %v", err)
return return
} }
w.w.PostMessage(&types.LabelList{Labels: tags}, nil) w.w.PostMessage(&types.LabelList{Labels: tags}, nil)
@ -642,19 +642,19 @@ func (w *worker) sort(uids []uint32,
for _, uid := range uids { for _, uid := range uids {
m, err := w.msgFromUid(uid) m, err := w.msgFromUid(uid)
if err != nil { if err != nil {
logging.Errorf("could not get message: %w", err) logging.Errorf("could not get message: %v", err)
continue continue
} }
info, err := m.MessageInfo() info, err := m.MessageInfo()
if err != nil { if err != nil {
logging.Errorf("could not get message info: %w", err) logging.Errorf("could not get message info: %v", err)
continue continue
} }
msgInfos = append(msgInfos, info) msgInfos = append(msgInfos, info)
} }
sortedUids, err := lib.Sort(msgInfos, criteria) sortedUids, err := lib.Sort(msgInfos, criteria)
if err != nil { if err != nil {
logging.Errorf("could not sort the messages: %w", err) logging.Errorf("could not sort the messages: %v", err)
return nil, err return nil, err
} }
return sortedUids, nil return sortedUids, nil

View file

@ -72,7 +72,7 @@ func (t *Thread) Uids() []uint32 {
return nil return nil
}) })
if err != nil { if err != nil {
logging.Errorf("walk to collect uids failed: %w", err) logging.Errorf("walk to collect uids failed: %v", err)
} }
return uids return uids
} }