1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-10-25 05:37:37 +03:00

Made error handling better

This commit is contained in:
mjarkk
2018-10-29 08:23:56 +01:00
parent 1e0310a86d
commit 9585f49490
4 changed files with 26 additions and 17 deletions

View File

@@ -57,7 +57,7 @@ func (c *OSCommand) RunCommandWithOutput(command string) (string, error) {
}
// RunCommandWithOutputLive runs RunCommandWithOutputLiveWrapper
func (c *OSCommand) RunCommandWithOutputLive(command string, output func(string) string) error {
func (c *OSCommand) RunCommandWithOutputLive(command string, output func(string) string) (errorMessage string, err error) {
return RunCommandWithOutputLiveWrapper(c, command, output)
}
@@ -66,7 +66,7 @@ func (c *OSCommand) RunCommandWithOutputLive(command string, output func(string)
// The ask argument will be "username" or "password" and expects the user's password or username back
func (c *OSCommand) DetectUnamePass(command string, ask func(string) string) error {
ttyText := ""
err := c.RunCommandWithOutputLive(command, func(word string) string {
errMessage, err := c.RunCommandWithOutputLive(command, func(word string) string {
ttyText = ttyText + " " + word
// detect username question
@@ -87,7 +87,11 @@ func (c *OSCommand) DetectUnamePass(command string, ask func(string) string) err
return ""
})
if err != nil {
return err
errorCode := err.Error()
if errorCode == "exit status 128" {
errMessage = errorCode
}
return errors.New(errMessage)
}
return nil
}