From feacca3c5caffb11be1f5f7cbfef01400b5bc944 Mon Sep 17 00:00:00 2001 From: Wagner Riffel Date: Tue, 3 Sep 2019 16:34:04 -0300 Subject: [PATCH] all: use fmt.Errorf for fomartting errors Signed-off-by: Wagner Riffel --- commands/account/next-folder.go | 2 +- commands/account/next-result.go | 2 +- commands/account/next.go | 2 +- commands/compose/next-field.go | 3 +-- commands/ct.go | 2 +- commands/msgview/next-part.go | 3 +-- commands/msgview/toggle-headers.go | 3 +-- commands/next-tab.go | 3 +-- commands/prompt.go | 3 +-- config/bindings.go | 2 +- 10 files changed, 10 insertions(+), 15 deletions(-) diff --git a/commands/account/next-folder.go b/commands/account/next-folder.go index 6a22772..037cd31 100644 --- a/commands/account/next-folder.go +++ b/commands/account/next-folder.go @@ -49,5 +49,5 @@ func (NextPrevFolder) Execute(aerc *widgets.Aerc, args []string) error { } func nextPrevFolderUsage(cmd string) error { - return errors.New(fmt.Sprintf("Usage: %s [n]", cmd)) + return fmt.Errorf("Usage: %s [n]", cmd) } diff --git a/commands/account/next-result.go b/commands/account/next-result.go index ab050af..78d437d 100644 --- a/commands/account/next-result.go +++ b/commands/account/next-result.go @@ -46,5 +46,5 @@ func (NextPrevResult) Execute(aerc *widgets.Aerc, args []string) error { } func nextPrevResultUsage(cmd string) error { - return errors.New(fmt.Sprintf("Usage: %s [[%%]]", cmd)) + return fmt.Errorf("Usage: %s [[%%]]", cmd) } diff --git a/commands/account/next.go b/commands/account/next.go index 604dcd7..e1d3eeb 100644 --- a/commands/account/next.go +++ b/commands/account/next.go @@ -78,5 +78,5 @@ func ExecuteNextPrevMessage(args []string, acct *widgets.AccountView, pct bool, } func nextPrevMessageUsage(cmd string) error { - return errors.New(fmt.Sprintf("Usage: %s [[%%]]", cmd)) + return fmt.Errorf("Usage: %s [[%%]]", cmd) } diff --git a/commands/compose/next-field.go b/commands/compose/next-field.go index 43ae644..a81852e 100644 --- a/commands/compose/next-field.go +++ b/commands/compose/next-field.go @@ -1,7 +1,6 @@ package compose import ( - "errors" "fmt" "git.sr.ht/~sircmpwn/aerc/widgets" @@ -35,5 +34,5 @@ func (NextPrevField) Execute(aerc *widgets.Aerc, args []string) error { } func nextPrevFieldUsage(cmd string) error { - return errors.New(fmt.Sprintf("Usage: %s", cmd)) + return fmt.Errorf("Usage: %s", cmd) } diff --git a/commands/ct.go b/commands/ct.go index f84e8a9..3cae0bd 100644 --- a/commands/ct.go +++ b/commands/ct.go @@ -34,7 +34,7 @@ func (ChangeTab) Complete(aerc *widgets.Aerc, args []string) []string { func (ChangeTab) Execute(aerc *widgets.Aerc, args []string) error { if len(args) != 2 { - return errors.New(fmt.Sprintf("Usage: %s ", args[0])) + return fmt.Errorf("Usage: %s ", args[0]) } if args[1] == "-" { ok := aerc.SelectPreviousTab() diff --git a/commands/msgview/next-part.go b/commands/msgview/next-part.go index c9423cc..a98e96a 100644 --- a/commands/msgview/next-part.go +++ b/commands/msgview/next-part.go @@ -1,7 +1,6 @@ package msgview import ( - "errors" "fmt" "strconv" @@ -48,5 +47,5 @@ func (NextPrevPart) Execute(aerc *widgets.Aerc, args []string) error { } func nextPrevPartUsage(cmd string) error { - return errors.New(fmt.Sprintf("Usage: %s [n]", cmd)) + return fmt.Errorf("Usage: %s [n]", cmd) } diff --git a/commands/msgview/toggle-headers.go b/commands/msgview/toggle-headers.go index f13e27d..e777d9b 100644 --- a/commands/msgview/toggle-headers.go +++ b/commands/msgview/toggle-headers.go @@ -1,7 +1,6 @@ package msgview import ( - "errors" "fmt" "git.sr.ht/~sircmpwn/aerc/widgets" @@ -31,5 +30,5 @@ func (ToggleHeaders) Execute(aerc *widgets.Aerc, args []string) error { } func toggleHeadersUsage(cmd string) error { - return errors.New(fmt.Sprintf("Usage: %s", cmd)) + return fmt.Errorf("Usage: %s", cmd) } diff --git a/commands/next-tab.go b/commands/next-tab.go index 5af8692..fc668f1 100644 --- a/commands/next-tab.go +++ b/commands/next-tab.go @@ -1,7 +1,6 @@ package commands import ( - "errors" "fmt" "strconv" @@ -47,5 +46,5 @@ func (NextPrevTab) Execute(aerc *widgets.Aerc, args []string) error { } func nextPrevTabUsage(cmd string) error { - return errors.New(fmt.Sprintf("Usage: %s [n]", cmd)) + return fmt.Errorf("Usage: %s [n]", cmd) } diff --git a/commands/prompt.go b/commands/prompt.go index fe152c8..2d6d01d 100644 --- a/commands/prompt.go +++ b/commands/prompt.go @@ -1,7 +1,6 @@ package commands import ( - "errors" "fmt" "git.sr.ht/~sircmpwn/aerc/widgets" @@ -23,7 +22,7 @@ func (Prompt) Complete(aerc *widgets.Aerc, args []string) []string { func (Prompt) Execute(aerc *widgets.Aerc, args []string) error { if len(args) < 3 { - return errors.New(fmt.Sprintf("Usage: %s ", args[0])) + return fmt.Errorf("Usage: %s ", args[0]) } prompt := args[1] diff --git a/config/bindings.go b/config/bindings.go index 46e6924..a19d4f3 100644 --- a/config/bindings.go +++ b/config/bindings.go @@ -122,7 +122,7 @@ func ParseKeyStrokes(keystrokes string) ([]KeyStroke, error) { if key, ok := keyNames[strings.ToLower(name)]; ok { strokes = append(strokes, key) } else { - return nil, errors.New(fmt.Sprintf("Unknown key '%s'", name)) + return nil, fmt.Errorf("Unknown key '%s'", name) } case '>': return nil, errors.New("Found '>' without '<'")