diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-03 13:43:43 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-06 19:34:32 +1000 |
commit | f1d7f59e497a2da9066494d04f26e1ff00a0e4ee (patch) | |
tree | f51b629766de0778f4e6b9cd37f44af9db0edaad /pkg/utils | |
parent | bc9a99387f68afb24863d17ab4d29c1686843a76 (diff) |
switching repos without restarting the gui
Diffstat (limited to 'pkg/utils')
-rw-r--r-- | pkg/utils/utils.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 339bcb0a9..945586001 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -365,6 +365,10 @@ func ResolveTemplate(templateStr string, object interface{}) (string, error) { // Safe will close tcell if a panic occurs so that we don't end up in a malformed // terminal state func Safe(f func()) { + _ = SafeWithError(func() error { f(); return nil }) +} + +func SafeWithError(f func() error) error { panicking := true defer func() { if panicking && gocui.Screen != nil { @@ -372,7 +376,9 @@ func Safe(f func()) { } }() - f() + err := f() panicking = false + + return err } |