dealing better with errors at the top level

This commit is contained in:
Jesse Duffield 2019-02-18 19:42:23 +11:00
parent 43ab7318d3
commit adc2529019
6 changed files with 30 additions and 12 deletions

17
main.go
View file

@ -8,6 +8,7 @@ import (
"path/filepath"
"runtime"
"github.com/go-errors/errors"
"github.com/jesseduffield/lazygit/pkg/app"
"github.com/jesseduffield/lazygit/pkg/config"
)
@ -44,11 +45,17 @@ func main() {
log.Fatal(err.Error())
}
app, err := app.Setup(appConfig)
if err != nil {
app.Log.Error(err.Error())
log.Fatal(err.Error())
app, err := app.NewApp(appConfig)
if err == nil {
err = app.Run()
}
app.Gui.RunWithSubprocesses()
if err != nil {
newErr := errors.Wrap(err, 0)
stackTrace := newErr.ErrorStack()
app.Log.Error(stackTrace)
log.Fatal(fmt.Sprintf("%s\n\n%s", app.Tr.SLocalize("ErrorOccurred"), stackTrace))
}
}