about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2021-01-30 13:51:32 +0100
committerReto Brunner <reto@labrat.space>2021-01-30 14:04:23 +0100
commit8ea86cea41aa038a25a8fee9cd540a7336869dae (patch)
tree11970859b928dfa06203962b58941e889295edc0
parent949781fa0a5f0654112b4f78558347ca991a89d3 (diff)
downloadaerc-8ea86cea41aa038a25a8fee9cd540a7336869dae.tar.gz
Get rid of the aerc.PushError(" " + $string) idiom
The individual callers should not be responsible for padding
-rw-r--r--commands/account/mkdir.go2
-rw-r--r--commands/account/rmdir.go2
-rw-r--r--commands/compose/attach.go4
-rw-r--r--commands/compose/postpone.go4
-rw-r--r--commands/exec.go2
-rw-r--r--commands/msg/archive.go2
-rw-r--r--commands/msg/copy.go2
-rw-r--r--commands/msg/delete.go2
-rw-r--r--commands/msg/modify-labels.go2
-rw-r--r--commands/msg/move.go2
-rw-r--r--commands/msg/pipe.go4
-rw-r--r--commands/msg/read.go2
-rw-r--r--commands/msg/recall.go2
-rw-r--r--commands/msgview/open.go6
-rw-r--r--commands/term.go2
-rw-r--r--commands/util.go4
-rw-r--r--widgets/account-wizard.go6
-rw-r--r--widgets/aerc.go8
18 files changed, 29 insertions, 29 deletions
diff --git a/commands/account/mkdir.go b/commands/account/mkdir.go
index 4352a42..d3a6226 100644
--- a/commands/account/mkdir.go
+++ b/commands/account/mkdir.go
@@ -40,7 +40,7 @@ func (MakeDir) Execute(aerc *widgets.Aerc, args []string) error {
 			aerc.PushStatus("Directory created.", 10*time.Second)
 			acct.Directories().Select(name)
 		case *types.Error:
-			aerc.PushError(" " + msg.Error.Error())
+			aerc.PushError(msg.Error.Error())
 		}
 	})
 	return nil
diff --git a/commands/account/rmdir.go b/commands/account/rmdir.go
index ed24ca5..9cd974f 100644
--- a/commands/account/rmdir.go
+++ b/commands/account/rmdir.go
@@ -86,7 +86,7 @@ func (RemoveDir) Execute(aerc *widgets.Aerc, args []string) error {
 		case *types.Done:
 			aerc.PushStatus("Directory removed.", 10*time.Second)
 		case *types.Error:
-			aerc.PushError(" " + msg.Error.Error())
+			aerc.PushError(msg.Error.Error())
 		case *types.Unsupported:
 			aerc.PushError(":rmdir is not supported by the backend.")
 		}
diff --git a/commands/compose/attach.go b/commands/compose/attach.go
index 148442b..37f49df 100644
--- a/commands/compose/attach.go
+++ b/commands/compose/attach.go
@@ -34,13 +34,13 @@ func (Attach) Execute(aerc *widgets.Aerc, args []string) error {
 
 	path, err := homedir.Expand(path)
 	if err != nil {
-		aerc.PushError(" " + err.Error())
+		aerc.PushError(err.Error())
 		return err
 	}
 
 	pathinfo, err := os.Stat(path)
 	if err != nil {
-		aerc.PushError(" " + err.Error())
+		aerc.PushError(err.Error())
 		return err
 	} else if pathinfo.IsDir() {
 		aerc.PushError("Attachment must be a file, not a directory")
diff --git a/commands/compose/postpone.go b/commands/compose/postpone.go
index 365b683..6d6c8e7 100644
--- a/commands/compose/postpone.go
+++ b/commands/compose/postpone.go
@@ -63,7 +63,7 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error {
 	go func() {
 		errStr := <-errChan
 		if errStr != "" {
-			aerc.PushError(" " + errStr)
+			aerc.PushError(errStr)
 			return
 		}
 
@@ -90,7 +90,7 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error {
 				r.Close()
 				composer.Close()
 			case *types.Error:
-				aerc.PushError(" " + msg.Error.Error())
+				aerc.PushError(msg.Error.Error())
 				r.Close()
 				composer.Close()
 			}
diff --git a/commands/exec.go b/commands/exec.go
index c9aba68..b1966c2 100644
--- a/commands/exec.go
+++ b/commands/exec.go
@@ -47,7 +47,7 @@ func (ExecCmd) Execute(aerc *widgets.Aerc, args []string) error {
 	go func() {
 		err := cmd.Run()
 		if err != nil {
-			aerc.PushError(" " + err.Error())
+			aerc.PushError(err.Error())
 		} else {
 			if cmd.ProcessState.ExitCode() != 0 {
 				aerc.PushError(fmt.Sprintf(
diff --git a/commands/msg/archive.go b/commands/msg/archive.go
index 07de13f..59ca985 100644
--- a/commands/msg/archive.go
+++ b/commands/msg/archive.go
@@ -86,7 +86,7 @@ func (Archive) Execute(aerc *widgets.Aerc, args []string) error {
 			case *types.Done:
 				wg.Done()
 			case *types.Error:
-				aerc.PushError(" " + msg.Error.Error())
+				aerc.PushError(msg.Error.Error())
 				success = false
 				wg.Done()
 			}
diff --git a/commands/msg/copy.go b/commands/msg/copy.go
index f3d4030..8e5bad0 100644
--- a/commands/msg/copy.go
+++ b/commands/msg/copy.go
@@ -60,7 +60,7 @@ func (Copy) Execute(aerc *widgets.Aerc, args []string) error {
 			case *types.Done:
 				aerc.PushStatus("Messages copied.", 10*time.Second)
 			case *types.Error:
-				aerc.PushError(" " + msg.Error.Error())
+				aerc.PushError(msg.Error.Error())
 			}
 		})
 	return nil
diff --git a/commands/msg/delete.go b/commands/msg/delete.go
index 6eb35eb..baa5011 100644
--- a/commands/msg/delete.go
+++ b/commands/msg/delete.go
@@ -47,7 +47,7 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
 		case *types.Done:
 			aerc.PushStatus("Messages deleted.", 10*time.Second)
 		case *types.Error:
-			aerc.PushError(" " + msg.Error.Error())
+			aerc.PushError(msg.Error.Error())
 		case *types.Unsupported:
 			// notmuch doesn't support it, we want the user to know
 			aerc.PushError(" error, unsupported for this worker")
diff --git a/commands/msg/modify-labels.go b/commands/msg/modify-labels.go
index f91075a..082742b 100644
--- a/commands/msg/modify-labels.go
+++ b/commands/msg/modify-labels.go
@@ -58,7 +58,7 @@ func (ModifyLabels) Execute(aerc *widgets.Aerc, args []string) error {
 		case *types.Done:
 			aerc.PushStatus("labels updated", 10*time.Second)
 		case *types.Error:
-			aerc.PushError(" " + msg.Error.Error())
+			aerc.PushError(msg.Error.Error())
 		}
 	})
 	return nil
diff --git a/commands/msg/move.go b/commands/msg/move.go
index 41f61da..31e243a 100644
--- a/commands/msg/move.go
+++ b/commands/msg/move.go
@@ -71,7 +71,7 @@ func (Move) Execute(aerc *widgets.Aerc, args []string) error {
 		case *types.Done:
 			aerc.PushStatus("Message moved to "+joinedArgs, 10*time.Second)
 		case *types.Error:
-			aerc.PushError(" " + msg.Error.Error())
+			aerc.PushError(msg.Error.Error())
 		}
 	})
 	return nil
diff --git a/commands/msg/pipe.go b/commands/msg/pipe.go
index 4e4ba67..0e22fd0 100644
--- a/commands/msg/pipe.go
+++ b/commands/msg/pipe.go
@@ -75,7 +75,7 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error {
 	doTerm := func(reader io.Reader, name string) {
 		term, err := commands.QuickTerm(aerc, cmd, reader)
 		if err != nil {
-			aerc.PushError(" " + err.Error())
+			aerc.PushError(err.Error())
 			return
 		}
 		aerc.NewTab(term, name)
@@ -93,7 +93,7 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error {
 		}()
 		err = ecmd.Run()
 		if err != nil {
-			aerc.PushError(" " + err.Error())
+			aerc.PushError(err.Error())
 		} else {
 			if ecmd.ProcessState.ExitCode() != 0 {
 				aerc.PushError(fmt.Sprintf(
diff --git a/commands/msg/read.go b/commands/msg/read.go
index 325b776..95becf7 100644
--- a/commands/msg/read.go
+++ b/commands/msg/read.go
@@ -187,7 +187,7 @@ func submitFlagChange(aerc *widgets.Aerc, store *lib.MessageStore,
 		case *types.Done:
 			wg.Done()
 		case *types.Error:
-			aerc.PushError(" " + msg.Error.Error())
+			aerc.PushError(msg.Error.Error())
 			*success = false
 			wg.Done()
 		}
diff --git a/commands/msg/recall.go b/commands/msg/recall.go
index b6c7f65..44f8ddf 100644
--- a/commands/msg/recall.go
+++ b/commands/msg/recall.go
@@ -86,7 +86,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
 			}, func(msg types.WorkerMessage) {
 				switch msg := msg.(type) {
 				case *types.Error:
-					aerc.PushError(" " + msg.Error.Error())
+					aerc.PushError(msg.Error.Error())
 					composer.Close()
 				}
 			})
diff --git a/commands/msgview/open.go b/commands/msgview/open.go
index 47b4369..57e7227 100644
--- a/commands/msgview/open.go
+++ b/commands/msgview/open.go
@@ -44,14 +44,14 @@ func (Open) Execute(aerc *widgets.Aerc, args []string) error {
 
 		tmpFile, err := ioutil.TempFile(os.TempDir(), "aerc-*"+extension)
 		if err != nil {
-			aerc.PushError(" " + err.Error())
+			aerc.PushError(err.Error())
 			return
 		}
 		defer tmpFile.Close()
 
 		_, err = io.Copy(tmpFile, reader)
 		if err != nil {
-			aerc.PushError(" " + err.Error())
+			aerc.PushError(err.Error())
 			return
 		}
 
@@ -68,7 +68,7 @@ func (Open) Execute(aerc *widgets.Aerc, args []string) error {
 		go func() {
 			err := xdg.Wait()
 			if err != nil {
-				aerc.PushError(" " + err.Error())
+				aerc.PushError(err.Error())
 			}
 		}()
 
diff --git a/commands/term.go b/commands/term.go
index 00f6937..c28c7d0 100644
--- a/commands/term.go
+++ b/commands/term.go
@@ -46,7 +46,7 @@ func TermCore(aerc *widgets.Aerc, args []string) error {
 	term.OnClose = func(err error) {
 		aerc.RemoveTab(term)
 		if err != nil {
-			aerc.PushError(" " + err.Error())
+			aerc.PushError(err.Error())
 		}
 	}
 	return nil
diff --git a/commands/util.go b/commands/util.go
index b1872bc..8e2bdbc 100644
--- a/commands/util.go
+++ b/commands/util.go
@@ -32,7 +32,7 @@ func QuickTerm(aerc *widgets.Aerc, args []string, stdin io.Reader) (*widgets.Ter
 
 	term.OnClose = func(err error) {
 		if err != nil {
-			aerc.PushError(" " + err.Error())
+			aerc.PushError(err.Error())
 			// remove the tab on error, otherwise it gets stuck
 			aerc.RemoveTab(term)
 		} else {
@@ -56,7 +56,7 @@ func QuickTerm(aerc *widgets.Aerc, args []string, stdin io.Reader) (*widgets.Ter
 
 		err := <-status
 		if err != nil {
-			aerc.PushError(" " + err.Error())
+			aerc.PushError(err.Error())
 		}
 	}
 
diff --git a/widgets/account-wizard.go b/widgets/account-wizard.go
index 71ba6e1..d8e2eb0 100644
--- a/widgets/account-wizard.go
+++ b/widgets/account-wizard.go
@@ -428,7 +428,7 @@ func (wizard *AccountWizard) ConfigureTemporaryAccount(temporary bool) {
 
 func (wizard *AccountWizard) errorFor(d ui.Interactive, err error) {
 	if d == nil {
-		wizard.aerc.PushError(" " + err.Error())
+		wizard.aerc.PushError(err.Error())
 		wizard.Invalidate()
 		return
 	}
@@ -443,7 +443,7 @@ func (wizard *AccountWizard) errorFor(d ui.Interactive, err error) {
 				wizard.step = step
 				wizard.focus = focus
 				wizard.Focus(true)
-				wizard.aerc.PushError(" " + err.Error())
+				wizard.aerc.PushError(err.Error())
 				wizard.Invalidate()
 				return
 			}
@@ -559,7 +559,7 @@ func (wizard *AccountWizard) finish(tutorial bool) {
 		term.OnClose = func(err error) {
 			wizard.aerc.RemoveTab(term)
 			if err != nil {
-				wizard.aerc.PushError(" " + err.Error())
+				wizard.aerc.PushError(err.Error())
 			}
 		}
 	}
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 01166b0..6df0c95 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -429,11 +429,11 @@ func (aerc *Aerc) BeginExCommand(cmd string) {
 	exline := NewExLine(aerc.conf, cmd, func(cmd string) {
 		parts, err := shlex.Split(cmd)
 		if err != nil {
-			aerc.PushError(" " + err.Error())
+			aerc.PushError(err.Error())
 		}
 		err = aerc.cmd(parts)
 		if err != nil {
-			aerc.PushError(" " + err.Error())
+			aerc.PushError(err.Error())
 		}
 		// only add to history if this is an unsimulated command,
 		// ie one not executed from a keybinding
@@ -457,7 +457,7 @@ func (aerc *Aerc) RegisterPrompt(prompt string, cmd []string) {
 		}
 		err := aerc.cmd(cmd)
 		if err != nil {
-			aerc.PushError(" " + err.Error())
+			aerc.PushError(err.Error())
 		}
 	}, func(cmd string) []string {
 		return nil // TODO: completions
@@ -484,7 +484,7 @@ func (aerc *Aerc) RegisterChoices(choices []Choice) {
 		}
 		err := aerc.cmd(cmd)
 		if err != nil {
-			aerc.PushError(" " + err.Error())
+			aerc.PushError(err.Error())
 		}
 	}, func(cmd string) []string {
 		return nil // TODO: completions