Skip to content

Commit

Permalink
GetTokenFromCLIWithParams fixed empty error message if command invoke…
Browse files Browse the repository at this point in the history
… failed. (#653)

* Fixed empty error message if cli invoke failed

* Addendum to last commit

* Check stderr for empty string

Co-authored-by: Joel Hendrix <jhendrix@microsoft.com>
  • Loading branch information
StiviiK and jhendrixMSFT committed Nov 5, 2021
1 parent 492f94b commit f434b9b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion autorest/azure/cli/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ func GetTokenFromCLIWithParams(params GetAccessTokenParams) (*Token, error) {

output, err := cliCmd.Output()
if err != nil {
return nil, fmt.Errorf("Invoking Azure CLI failed with the following error: %s", stderr.String())
if stderr.Len() > 0 {
return nil, fmt.Errorf("Invoking Azure CLI failed with the following error: %s", stderr.String())
}

return nil, fmt.Errorf("Invoking Azure CLI failed with the following error: %s", err.Error())
}

tokenResponse := Token{}
Expand Down

0 comments on commit f434b9b

Please sign in to comment.