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
943'>943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233