diff options
author | Elwardi <elwardifadeli@gmail.com> | 2021-07-19 13:31:44 +0100 |
---|---|---|
committer | Elwardi <elwardifadeli@gmail.com> | 2021-07-19 13:41:42 +0100 |
commit | f70435a20fb9641513aff9c94ea368973c39d252 (patch) | |
tree | 633ffcdfa553f5c534b75d0c0490757744447240 /pkg | |
parent | b92ff3ee3fdde05ac84f2790e6b10a10db0c4d2a (diff) |
Better format error catching in menuFromCommand prompts
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/custom_commands.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/pkg/gui/custom_commands.go b/pkg/gui/custom_commands.go index 1ac92f49c..c258b600f 100644 --- a/pkg/gui/custom_commands.go +++ b/pkg/gui/custom_commands.go @@ -185,7 +185,10 @@ func (gui *Gui) handleCustomCommandKeybinding(customCommand config.CustomCommand // Need to make a menu out of what the cmd has displayed candidates := []string{} buff := bytes.NewBuffer(nil) - temp := template.Must(template.New("format").Parse(prompt.Format)) + temp, err := template.New("format").Parse(prompt.Format) + if err != nil { + return gui.surfaceError(errors.New("unable to parse format, error: " + err.Error())) + } for _, str := range strings.Split(string(message), "\n") { if str == "" { continue @@ -203,7 +206,11 @@ func (gui *Gui) handleCustomCommandKeybinding(customCommand config.CustomCommand } } } - temp.Execute(buff, tmplData) + err = temp.Execute(buff, tmplData) + if err != nil { + return gui.surfaceError(err) + } + candidates = append(candidates, strings.TrimSpace(buff.String())) buff.Reset() } |