()
| 290 | } |
| 291 | |
| 292 | func (err httpError) Error() string { |
| 293 | if err.StatusCode != 422 || len(err.Errors) == 0 { |
| 294 | return fmt.Sprintf("HTTP %d: %s (%s)", err.StatusCode, err.Message, err.RequestURL) |
| 295 | } |
| 296 | query := strings.TrimSpace(err.RequestURL.Query().Get("q")) |
| 297 | return fmt.Sprintf("Invalid search query %q.\n%s", query, err.Errors[0].Message) |
| 298 | } |
| 299 | |
| 300 | func handleHTTPError(resp *http.Response) error { |
| 301 | httpError := httpError{ |