Use aerc.PushError where appropriate

Forgot an unused import, to save you the hassle here is v2.
This commit is contained in:
Ben Fiedler 2020-04-23 03:56:28 +02:00 committed by Reto Brunner
parent 280d8e7e1c
commit 7c89143c70
13 changed files with 20 additions and 52 deletions

View File

@ -5,8 +5,6 @@ import (
"strings" "strings"
"time" "time"
"github.com/gdamore/tcell"
"git.sr.ht/~sircmpwn/aerc/widgets" "git.sr.ht/~sircmpwn/aerc/widgets"
"git.sr.ht/~sircmpwn/aerc/worker/types" "git.sr.ht/~sircmpwn/aerc/worker/types"
) )
@ -42,8 +40,7 @@ func (MakeDir) Execute(aerc *widgets.Aerc, args []string) error {
aerc.PushStatus("Directory created.", 10*time.Second) aerc.PushStatus("Directory created.", 10*time.Second)
acct.Directories().Select(name) acct.Directories().Select(name)
case *types.Error: case *types.Error:
aerc.PushStatus(" "+msg.Error.Error(), 10*time.Second). aerc.PushError(" "+msg.Error.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
} }
}) })
return nil return nil

View File

@ -246,8 +246,7 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
r.Close() r.Close()
composer.Close() composer.Close()
case *types.Error: case *types.Error:
aerc.PushStatus(" "+msg.Error.Error(), 10*time.Second). aerc.PushError(" "+msg.Error.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
r.Close() r.Close()
composer.Close() composer.Close()
} }

View File

@ -33,8 +33,7 @@ func (ExecCmd) Execute(aerc *widgets.Aerc, args []string) error {
go func() { go func() {
err := cmd.Run() err := cmd.Run()
if err != nil { if err != nil {
aerc.PushStatus(" "+err.Error(), 10*time.Second). aerc.PushError(" "+err.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
} else { } else {
color := tcell.ColorDefault color := tcell.ColorDefault
if cmd.ProcessState.ExitCode() != 0 { if cmd.ProcessState.ExitCode() != 0 {

View File

@ -7,8 +7,6 @@ import (
"sync" "sync"
"time" "time"
"github.com/gdamore/tcell"
"git.sr.ht/~sircmpwn/aerc/commands" "git.sr.ht/~sircmpwn/aerc/commands"
"git.sr.ht/~sircmpwn/aerc/models" "git.sr.ht/~sircmpwn/aerc/models"
"git.sr.ht/~sircmpwn/aerc/widgets" "git.sr.ht/~sircmpwn/aerc/widgets"
@ -88,8 +86,7 @@ func (Archive) Execute(aerc *widgets.Aerc, args []string) error {
case *types.Done: case *types.Done:
wg.Done() wg.Done()
case *types.Error: case *types.Error:
aerc.PushStatus(" "+msg.Error.Error(), 10*time.Second). aerc.PushError(" "+msg.Error.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
success = false success = false
wg.Done() wg.Done()
} }

View File

@ -6,7 +6,6 @@ import (
"time" "time"
"git.sr.ht/~sircmpwn/getopt" "git.sr.ht/~sircmpwn/getopt"
"github.com/gdamore/tcell"
"git.sr.ht/~sircmpwn/aerc/commands" "git.sr.ht/~sircmpwn/aerc/commands"
"git.sr.ht/~sircmpwn/aerc/widgets" "git.sr.ht/~sircmpwn/aerc/widgets"
@ -61,8 +60,7 @@ func (Copy) Execute(aerc *widgets.Aerc, args []string) error {
case *types.Done: case *types.Done:
aerc.PushStatus("Messages copied.", 10*time.Second) aerc.PushStatus("Messages copied.", 10*time.Second)
case *types.Error: case *types.Error:
aerc.PushStatus(" "+msg.Error.Error(), 10*time.Second). aerc.PushError(" "+msg.Error.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
} }
}) })
return nil return nil

View File

@ -4,8 +4,6 @@ import (
"errors" "errors"
"time" "time"
"github.com/gdamore/tcell"
"git.sr.ht/~sircmpwn/aerc/lib" "git.sr.ht/~sircmpwn/aerc/lib"
"git.sr.ht/~sircmpwn/aerc/models" "git.sr.ht/~sircmpwn/aerc/models"
"git.sr.ht/~sircmpwn/aerc/widgets" "git.sr.ht/~sircmpwn/aerc/widgets"
@ -49,8 +47,7 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
case *types.Done: case *types.Done:
aerc.PushStatus("Messages deleted.", 10*time.Second) aerc.PushStatus("Messages deleted.", 10*time.Second)
case *types.Error: case *types.Error:
aerc.PushStatus(" "+msg.Error.Error(), 10*time.Second). aerc.PushError(" "+msg.Error.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
} }
}) })

View File

@ -7,7 +7,6 @@ import (
"git.sr.ht/~sircmpwn/aerc/commands" "git.sr.ht/~sircmpwn/aerc/commands"
"git.sr.ht/~sircmpwn/aerc/widgets" "git.sr.ht/~sircmpwn/aerc/widgets"
"git.sr.ht/~sircmpwn/aerc/worker/types" "git.sr.ht/~sircmpwn/aerc/worker/types"
"github.com/gdamore/tcell"
) )
type ModifyLabels struct{} type ModifyLabels struct{}
@ -59,8 +58,7 @@ func (ModifyLabels) Execute(aerc *widgets.Aerc, args []string) error {
case *types.Done: case *types.Done:
aerc.PushStatus("labels updated", 10*time.Second) aerc.PushStatus("labels updated", 10*time.Second)
case *types.Error: case *types.Error:
aerc.PushStatus(" "+msg.Error.Error(), 10*time.Second). aerc.PushError(" "+msg.Error.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
} }
}) })
return nil return nil

View File

@ -6,7 +6,6 @@ import (
"time" "time"
"git.sr.ht/~sircmpwn/getopt" "git.sr.ht/~sircmpwn/getopt"
"github.com/gdamore/tcell"
"git.sr.ht/~sircmpwn/aerc/commands" "git.sr.ht/~sircmpwn/aerc/commands"
"git.sr.ht/~sircmpwn/aerc/widgets" "git.sr.ht/~sircmpwn/aerc/widgets"
@ -72,8 +71,7 @@ func (Move) Execute(aerc *widgets.Aerc, args []string) error {
case *types.Done: case *types.Done:
aerc.PushStatus("Message moved to "+joinedArgs, 10*time.Second) aerc.PushStatus("Message moved to "+joinedArgs, 10*time.Second)
case *types.Error: case *types.Error:
aerc.PushStatus(" "+msg.Error.Error(), 10*time.Second). aerc.PushError(" "+msg.Error.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
} }
}) })
return nil return nil

View File

@ -93,8 +93,7 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error {
}() }()
err = ecmd.Run() err = ecmd.Run()
if err != nil { if err != nil {
aerc.PushStatus(" "+err.Error(), 10*time.Second). aerc.PushError(" "+err.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
} else { } else {
color := tcell.ColorDefault color := tcell.ColorDefault
if ecmd.ProcessState.ExitCode() != 0 { if ecmd.ProcessState.ExitCode() != 0 {

View File

@ -7,8 +7,6 @@ import (
"git.sr.ht/~sircmpwn/getopt" "git.sr.ht/~sircmpwn/getopt"
"github.com/gdamore/tcell"
"git.sr.ht/~sircmpwn/aerc/lib" "git.sr.ht/~sircmpwn/aerc/lib"
"git.sr.ht/~sircmpwn/aerc/models" "git.sr.ht/~sircmpwn/aerc/models"
"git.sr.ht/~sircmpwn/aerc/widgets" "git.sr.ht/~sircmpwn/aerc/widgets"
@ -95,8 +93,7 @@ func submitReadChange(aerc *widgets.Aerc, store *lib.MessageStore,
case *types.Done: case *types.Done:
aerc.PushStatus(msg_success, 10*time.Second) aerc.PushStatus(msg_success, 10*time.Second)
case *types.Error: case *types.Error:
aerc.PushStatus(" "+msg.Error.Error(), 10*time.Second). aerc.PushError(" "+msg.Error.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
} }
}) })
} }
@ -109,8 +106,7 @@ func submitReadChangeWg(aerc *widgets.Aerc, store *lib.MessageStore,
case *types.Done: case *types.Done:
wg.Done() wg.Done()
case *types.Error: case *types.Error:
aerc.PushStatus(" "+msg.Error.Error(), 10*time.Second). aerc.PushError(" "+msg.Error.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
*success = false *success = false
wg.Done() wg.Done()
} }

View File

@ -2,12 +2,10 @@ package commands
import ( import (
"os/exec" "os/exec"
"time"
"github.com/riywo/loginshell"
"git.sr.ht/~sircmpwn/aerc/widgets" "git.sr.ht/~sircmpwn/aerc/widgets"
"github.com/gdamore/tcell"
"github.com/riywo/loginshell"
) )
type Term struct{} type Term struct{}
@ -48,8 +46,7 @@ func TermCore(aerc *widgets.Aerc, args []string) error {
term.OnClose = func(err error) { term.OnClose = func(err error) {
aerc.RemoveTab(term) aerc.RemoveTab(term)
if err != nil { if err != nil {
aerc.PushStatus(" "+err.Error(), 10*time.Second). aerc.PushError(" "+err.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
} }
} }
return nil return nil

View File

@ -10,7 +10,6 @@ import (
"path" "path"
"strconv" "strconv"
"strings" "strings"
"time"
"github.com/gdamore/tcell" "github.com/gdamore/tcell"
"github.com/go-ini/ini" "github.com/go-ini/ini"
@ -415,8 +414,7 @@ func (wizard *AccountWizard) ConfigureTemporaryAccount(temporary bool) {
func (wizard *AccountWizard) errorFor(d ui.Interactive, err error) { func (wizard *AccountWizard) errorFor(d ui.Interactive, err error) {
if d == nil { if d == nil {
wizard.aerc.PushStatus(" "+err.Error(), 10*time.Second). wizard.aerc.PushError(" "+err.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
wizard.Invalidate() wizard.Invalidate()
return return
} }
@ -431,8 +429,7 @@ func (wizard *AccountWizard) errorFor(d ui.Interactive, err error) {
wizard.step = step wizard.step = step
wizard.focus = focus wizard.focus = focus
wizard.Focus(true) wizard.Focus(true)
wizard.aerc.PushStatus(" "+err.Error(), 10*time.Second). wizard.aerc.PushError(" "+err.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
wizard.Invalidate() wizard.Invalidate()
return return
} }
@ -543,8 +540,7 @@ func (wizard *AccountWizard) finish(tutorial bool) {
term.OnClose = func(err error) { term.OnClose = func(err error) {
wizard.aerc.RemoveTab(term) wizard.aerc.RemoveTab(term)
if err != nil { if err != nil {
wizard.aerc.PushStatus(" "+err.Error(), 10*time.Second). wizard.aerc.PushError(" "+err.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
} }
} }
} }

View File

@ -408,13 +408,11 @@ func (aerc *Aerc) BeginExCommand(cmd string) {
exline := NewExLine(aerc.conf, cmd, func(cmd string) { exline := NewExLine(aerc.conf, cmd, func(cmd string) {
parts, err := shlex.Split(cmd) parts, err := shlex.Split(cmd)
if err != nil { if err != nil {
aerc.PushStatus(" "+err.Error(), 10*time.Second). aerc.PushError(" "+err.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
} }
err = aerc.cmd(parts) err = aerc.cmd(parts)
if err != nil { if err != nil {
aerc.PushStatus(" "+err.Error(), 10*time.Second). aerc.PushError(" "+err.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
} }
// only add to history if this is an unsimulated command, // only add to history if this is an unsimulated command,
// ie one not executed from a keybinding // ie one not executed from a keybinding
@ -438,8 +436,7 @@ func (aerc *Aerc) RegisterPrompt(prompt string, cmd []string) {
} }
err := aerc.cmd(cmd) err := aerc.cmd(cmd)
if err != nil { if err != nil {
aerc.PushStatus(" "+err.Error(), 10*time.Second). aerc.PushError(" "+err.Error())
Color(tcell.ColorDefault, tcell.ColorRed)
} }
}, func(cmd string) []string { }, func(cmd string) []string {
return nil // TODO: completions return nil // TODO: completions