diff options
author | mjarkk <mkopenga@gmail.com> | 2018-10-29 08:23:56 +0100 |
---|---|---|
committer | mjarkk <mkopenga@gmail.com> | 2018-10-29 08:23:56 +0100 |
commit | 9585f494906df62f26202b5c92d5cff027a10a36 (patch) | |
tree | d1d900a095cca9008fb4fe3a208a40f3658aa9d3 /pkg/commands/os.go | |
parent | 1e0310a86d61356d68c77a8e64bb572f0aaabeda (diff) |
Made error handling better
Diffstat (limited to 'pkg/commands/os.go')
-rw-r--r-- | pkg/commands/os.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/pkg/commands/os.go b/pkg/commands/os.go index 28c01813b..dca0c8eae 100644 --- a/pkg/commands/os.go +++ b/pkg/commands/os.go @@ -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 } |