jesseduffield / lazygit

simple terminal UI for git commands

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Better global error handling

stefanhaller opened this issue · comments

Right now, all entry points into the codebase (e.g. event handlers) need to catch errors and present them in an error panel, so we have tons of calls to self.c.Error(err) in the controller and helper classes. It's easy to forget this, however, and simply return the error instead, which will cause a panic in gocui (see #3490 for an example).

It would be much nicer if we could simply return errors everywhere, and gocui would take care of showing an error box after handling an event that returned an error. To do this gocui.Gui just needs an error callback, this seems very easy (see also the last paragraph of this long comment, starting with "As for surfacing the error..."). It seems we could then hopefully get rid of IPopupHandler.Error.