1
0
mirror of https://git.sr.ht/~sircmpwn/aerc synced 2024-11-23 00:21:59 +01:00

Get rid of the aerc.PushError(" " + $string) idiom

The individual callers should not be responsible for padding
This commit is contained in:
Reto Brunner 2021-01-30 13:51:32 +01:00
parent 949781fa0a
commit 8ea86cea41
18 changed files with 29 additions and 29 deletions

@ -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

@ -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.")
}

@ -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")

@ -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()
}

@ -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(

@ -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()
}

@ -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

@ -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")

@ -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

@ -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

@ -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(

@ -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()
}

@ -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()
}
})

@ -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())
}
}()

@ -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

@ -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())
}
}

@ -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())
}
}
}

@ -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