aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/msgviewer.go
diff options
context:
space:
mode:
authorMoritz Poldrack <git@moritz.sh>2022-07-29 22:31:54 +0200
committerRobin Jarry <robin@jarry.cc>2022-08-04 21:57:57 +0200
commit5ca6022d007bc83daba1e7297480d37f56554455 (patch)
treecc592d08276b7f0c8db6a4280bb7fb648b2548fe /widgets/msgviewer.go
parenta8d631177f4315810f0ab7c7d66d38e332ab0916 (diff)
downloadaerc-5ca6022d007bc83daba1e7297480d37f56554455.tar.gz
lint: ensure errors are at least logged (errcheck)
Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/msgviewer.go')
-rw-r--r--widgets/msgviewer.go40
1 files changed, 32 insertions, 8 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index be578b93..115eb3f1 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -645,7 +645,10 @@ func (pv *PartViewer) attemptCopy() {
pv.copySourceToSinkStripAnsi()
} else {
// if it's binary we have to rely on the filter to be sane
- io.Copy(pv.sink, pv.source)
+ _, err := io.Copy(pv.sink, pv.source)
+ if err != nil {
+ logging.Warnf("failed to copy: %w", err)
+ }
}
pv.sink.Close()
}()
@@ -667,14 +670,23 @@ func (pv *PartViewer) writeMailHeaders() {
}
field := fmt.Sprintf(
"%s: %s\n", fields.Key(), value)
- pv.pagerin.Write([]byte(field))
+ _, err = pv.pagerin.Write([]byte(field))
+ if err != nil {
+ logging.Errorf("failed to write to stdin of pager: %v", err)
+ }
}
// virtual header
if len(info.Labels) != 0 {
labels := fmtHeader(info, "Labels", "")
- pv.pagerin.Write([]byte(fmt.Sprintf("Labels: %s\n", labels)))
+ _, err := pv.pagerin.Write([]byte(fmt.Sprintf("Labels: %s\n", labels)))
+ if err != nil {
+ logging.Errorf("failed to write to stdin of pager: %v", err)
+ }
+ }
+ _, err := pv.pagerin.Write([]byte{'\n'})
+ if err != nil {
+ logging.Errorf("failed to write to stdin of pager: %v", err)
}
- pv.pagerin.Write([]byte{'\n'})
}
}
@@ -689,7 +701,10 @@ func (pv *PartViewer) hyperlinks(r io.Reader) (reader io.Reader) {
func (pv *PartViewer) copyFilterOutToPager() {
stdout, _ := pv.filter.StdoutPipe()
stderr, _ := pv.filter.StderrPipe()
- pv.filter.Start()
+ err := pv.filter.Start()
+ if err != nil {
+ logging.Warnf("failed to start filter: %v", err)
+ }
ch := make(chan interface{})
go func() {
defer logging.PanicHandler()
@@ -718,7 +733,10 @@ func (pv *PartViewer) copyFilterOutToPager() {
<-ch
<-ch
- pv.filter.Wait()
+ err := pv.filter.Wait()
+ if err != nil {
+ logging.Warnf("failed to wait for the filter process: %v", err)
+ }
pv.pagerin.Close()
}()
}
@@ -732,7 +750,10 @@ func (pv *PartViewer) copySourceToSinkStripAnsi() {
for scanner.Scan() {
text := scanner.Text()
text = ansi.ReplaceAllString(text, "")
- io.WriteString(pv.sink, text+"\n")
+ _, err := io.WriteString(pv.sink, text+"\n")
+ if err != nil {
+ logging.Warnf("failed write ", err)
+ }
}
if err := scanner.Err(); err != nil {
fmt.Fprintf(os.Stderr, "failed to read line: %v\n", err)
@@ -819,7 +840,10 @@ func (pv *PartViewer) Draw(ctx *ui.Context) {
func (pv *PartViewer) Cleanup() {
if pv.pager != nil && pv.pager.Process != nil {
- pv.pager.Process.Kill()
+ err := pv.pager.Process.Kill()
+ if err != nil {
+ logging.Warnf("failed to kill pager process: %v", err)
+ }
pv.pager = nil
}
}