aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/account/compose.go7
-rw-r--r--commands/account/recover.go7
-rw-r--r--commands/compose/postpone.go3
-rw-r--r--commands/compose/send.go5
-rw-r--r--commands/exec.go3
-rw-r--r--commands/msg/archive.go3
-rw-r--r--commands/msg/pipe.go5
-rw-r--r--commands/msg/read.go3
-rw-r--r--commands/msgview/open.go3
-rw-r--r--commands/msgview/save.go3
-rw-r--r--commands/util.go3
11 files changed, 43 insertions, 2 deletions
diff --git a/commands/account/compose.go b/commands/account/compose.go
index 1a62d0a3..4884b113 100644
--- a/commands/account/compose.go
+++ b/commands/account/compose.go
@@ -5,6 +5,7 @@ import (
"regexp"
"strings"
+ "git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~sircmpwn/getopt"
@@ -52,7 +53,11 @@ func (Compose) Execute(aerc *widgets.Aerc, args []string) error {
}
tab.Content.Invalidate()
})
- go composer.AppendContents(strings.NewReader(body))
+ go func() {
+ defer logging.PanicHandler()
+
+ composer.AppendContents(strings.NewReader(body))
+ }()
return nil
}
diff --git a/commands/account/recover.go b/commands/account/recover.go
index 8158af61..165e88e8 100644
--- a/commands/account/recover.go
+++ b/commands/account/recover.go
@@ -8,6 +8,7 @@ import (
"path/filepath"
"git.sr.ht/~rjarry/aerc/commands"
+ "git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~sircmpwn/getopt"
@@ -111,7 +112,11 @@ func (Recover) Execute(aerc *widgets.Aerc, args []string) error {
tab.Name = subject
tab.Content.Invalidate()
})
- go composer.AppendContents(bytes.NewReader(data))
+ go func() {
+ defer logging.PanicHandler()
+
+ composer.AppendContents(bytes.NewReader(data))
+ }()
// remove file if force flag is set
if force {
diff --git a/commands/compose/postpone.go b/commands/compose/postpone.go
index 9462a9cd..a4ac5c60 100644
--- a/commands/compose/postpone.go
+++ b/commands/compose/postpone.go
@@ -8,6 +8,7 @@ import (
"github.com/miolini/datacounter"
"github.com/pkg/errors"
+ "git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~rjarry/aerc/worker/types"
@@ -66,6 +67,8 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error {
// run this as a goroutine so we can make other progress. The message
// will be saved once the directory is created.
go func() {
+ defer logging.PanicHandler()
+
errStr := <-errChan
if errStr != "" {
aerc.PushError(errStr)
diff --git a/commands/compose/send.go b/commands/compose/send.go
index dbdb94f9..574e8727 100644
--- a/commands/compose/send.go
+++ b/commands/compose/send.go
@@ -16,6 +16,7 @@ import (
"github.com/pkg/errors"
"git.sr.ht/~rjarry/aerc/lib"
+ "git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~rjarry/aerc/worker/types"
@@ -100,6 +101,8 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
failCh := make(chan error)
//writer
go func() {
+ defer logging.PanicHandler()
+
var sender io.WriteCloser
switch ctx.scheme {
case "smtp":
@@ -131,6 +134,8 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
//cleanup + copy to sent
go func() {
+ defer logging.PanicHandler()
+
err = <-failCh
if err != nil {
aerc.PushError(strings.ReplaceAll(err.Error(), "\n", " "))
diff --git a/commands/exec.go b/commands/exec.go
index 317bf07a..bce62bd7 100644
--- a/commands/exec.go
+++ b/commands/exec.go
@@ -7,6 +7,7 @@ import (
"os/exec"
"time"
+ "git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/widgets"
)
@@ -45,6 +46,8 @@ func (ExecCmd) Execute(aerc *widgets.Aerc, args []string) error {
cmd.Env = env
go func() {
+ defer logging.PanicHandler()
+
err := cmd.Run()
if err != nil {
aerc.PushError(err.Error())
diff --git a/commands/msg/archive.go b/commands/msg/archive.go
index 8f832e58..ebe63ff3 100644
--- a/commands/msg/archive.go
+++ b/commands/msg/archive.go
@@ -8,6 +8,7 @@ import (
"time"
"git.sr.ht/~rjarry/aerc/commands"
+ "git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~rjarry/aerc/worker/types"
@@ -94,6 +95,8 @@ func (Archive) Execute(aerc *widgets.Aerc, args []string) error {
}
// we need to do that in the background, else we block the main thread
go func() {
+ defer logging.PanicHandler()
+
wg.Wait()
if success {
aerc.PushStatus("Messages archived.", 10*time.Second)
diff --git a/commands/msg/pipe.go b/commands/msg/pipe.go
index 5d8a0424..06f2a4d2 100644
--- a/commands/msg/pipe.go
+++ b/commands/msg/pipe.go
@@ -9,6 +9,7 @@ import (
"time"
"git.sr.ht/~rjarry/aerc/commands"
+ "git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~rjarry/aerc/worker/types"
@@ -89,6 +90,8 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error {
return
}
go func() {
+ defer logging.PanicHandler()
+
defer pipe.Close()
io.Copy(pipe, reader)
}()
@@ -146,6 +149,8 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error {
})
go func() {
+ defer logging.PanicHandler()
+
select {
case <-done:
break
diff --git a/commands/msg/read.go b/commands/msg/read.go
index d2484d45..4f8880a8 100644
--- a/commands/msg/read.go
+++ b/commands/msg/read.go
@@ -8,6 +8,7 @@ import (
"git.sr.ht/~sircmpwn/getopt"
"git.sr.ht/~rjarry/aerc/lib"
+ "git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~rjarry/aerc/worker/types"
@@ -169,6 +170,8 @@ func (FlagMsg) Execute(aerc *widgets.Aerc, args []string) error {
// We need to do flagging in the background, else we block the main thread
go func() {
+ defer logging.PanicHandler()
+
wg.Wait()
if success {
aerc.PushStatus(actionName+" flag '"+flagName+"' successful", 10*time.Second)
diff --git a/commands/msgview/open.go b/commands/msgview/open.go
index 5b199120..d8a4de01 100644
--- a/commands/msgview/open.go
+++ b/commands/msgview/open.go
@@ -9,6 +9,7 @@ import (
"time"
"git.sr.ht/~rjarry/aerc/lib"
+ "git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/widgets"
)
@@ -66,6 +67,8 @@ func (Open) Execute(aerc *widgets.Aerc, args []string) error {
return
}
go func() {
+ defer logging.PanicHandler()
+
err := xdg.Wait()
if err != nil {
aerc.PushError(err.Error())
diff --git a/commands/msgview/save.go b/commands/msgview/save.go
index 26a6bf2e..48add989 100644
--- a/commands/msgview/save.go
+++ b/commands/msgview/save.go
@@ -13,6 +13,7 @@ import (
"github.com/mitchellh/go-homedir"
"git.sr.ht/~rjarry/aerc/commands"
+ "git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
)
@@ -126,6 +127,8 @@ func (Save) Execute(aerc *widgets.Aerc, args []string) error {
// we need to wait for the callback prior to displaying a result
go func() {
+ defer logging.PanicHandler()
+
err := <-ch
if err != nil {
aerc.PushError(fmt.Sprintf("Save failed: %v", err))
diff --git a/commands/util.go b/commands/util.go
index 92b851a4..1c4a8c9a 100644
--- a/commands/util.go
+++ b/commands/util.go
@@ -13,6 +13,7 @@ import (
"github.com/lithammer/fuzzysearch/fuzzy"
"git.sr.ht/~rjarry/aerc/lib"
+ "git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
"github.com/gdamore/tcell/v2"
@@ -51,6 +52,8 @@ func QuickTerm(aerc *widgets.Aerc, args []string, stdin io.Reader) (*widgets.Ter
status := make(chan error, 1)
go func() {
+ defer logging.PanicHandler()
+
_, err := io.Copy(pipe, stdin)
defer pipe.Close()
status <- err