Skip to content

Commit

Permalink
Merge pull request nutanix#148 from scott-grimes/improvedErrorHandling
Browse files Browse the repository at this point in the history
provide better error reporting when invalid nutanix credentials are used
  • Loading branch information
marinsalinas authored Nov 17, 2020
2 parents 87fff49 + daf5c05 commit d1a1071
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ func CheckResponse(r *http.Response) error {
if c := r.StatusCode; c >= 200 && c <= 299 {
return nil
}

// Nutanix returns non-json response with code 401 when
// invalid credentials are used
if c == 401 {
return fmt.Errorf("Invalid Nutanix Credentials")
}

buf, err := ioutil.ReadAll(r.Body)

Expand Down

0 comments on commit d1a1071

Please sign in to comment.