()
| 311 | } |
| 312 | |
| 313 | func (err httpError) Error() string { |
| 314 | if err.StatusCode != 422 || len(err.Errors) == 0 { |
| 315 | return fmt.Sprintf("HTTP %d: %s (%s)", err.StatusCode, err.Message, err.RequestURL) |
| 316 | } |
| 317 | query := strings.TrimSpace(err.RequestURL.Query().Get("q")) |
| 318 | return fmt.Sprintf("Invalid search query %q.\n%s", query, err.Errors[0].Message) |
| 319 | } |
| 320 | |
| 321 | func handleHTTPError(resp *http.Response) error { |
| 322 | httpError := httpError{ |