Skip to content

Commit

Permalink
handle error in Ping()
Browse files Browse the repository at this point in the history
  • Loading branch information
bshore committed May 27, 2021
1 parent 923a516 commit 9b8a378
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion hirezapi/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ import (
func (a *APIClient) Ping() error {
url := fmt.Sprintf("%s/%s%s", a.BasePath, "ping", a.RespType)
resp, err := http.Get(url)
if resp.StatusCode != http.StatusOK {
if err != nil {
return err
}
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("error: Ping() did not return status 200: %d, Response: %s", resp.StatusCode, resp.Body)
}
return nil
}

Expand Down

0 comments on commit 9b8a378

Please sign in to comment.