(response *http.Response)
| 157 | var errNotFound = errors.New("invalid endpoint or API call") |
| 158 | |
| 159 | func checkResponse(response *http.Response) error { |
| 160 | if response.StatusCode == http.StatusNotFound { |
| 161 | return errNotFound |
| 162 | } else if response.StatusCode == http.StatusUnauthorized { |
| 163 | return errors.New("invalid API key") |
| 164 | } else if response.StatusCode != http.StatusOK { |
| 165 | data, err := responseToBArray(response) |
| 166 | if err != nil { |
| 167 | return err |
| 168 | } |
| 169 | body := strings.TrimSpace(string(data)) |
| 170 | return fmt.Errorf("unexpected HTTP status returned: %s\n%s", response.Status, body) |
| 171 | } |
| 172 | return nil |
| 173 | } |
no test coverage detected