diff options
author | David Chen <weichen2000121@gmail.com> | 2019-12-04 19:16:47 -0800 |
---|---|---|
committer | David Chen <weichen2000121@gmail.com> | 2019-12-04 19:16:47 -0800 |
commit | 1dbfea54bc84c039bfac8d4df3fcefb9ecd133a4 (patch) | |
tree | e69066ee325a5fa927b68c72171c8918a1e61bf6 /pkg/gui/keybindings.go | |
parent | 0af8784707b1f3bb9970812d1c21bcd2f839c6fd (diff) |
better error handling
Diffstat (limited to 'pkg/gui/keybindings.go')
-rw-r--r-- | pkg/gui/keybindings.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 634830e6c..7ea457bfd 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -2,6 +2,7 @@ package gui import ( "github.com/jesseduffield/gocui" + "log" "strings" ) @@ -140,10 +141,16 @@ var keymap = map[string]interface{}{ func (gui *Gui) getKey(name string) interface{} { key := gui.Config.GetUserConfig().GetString("keybinding." + name) if len(key) > 1 { - return keymap[strings.ToLower(key)] + binding := keymap[strings.ToLower(key)] + if binding == nil { + log.Fatal("Unrecognized binding: " + strings.ToLower(key)) + } else { + return binding + } } else if len(key) == 1 { return []rune(key)[0] } + log.Fatal("Key empty for function: " + strings.ToLower(name)) return nil } |