()
| 310 | } |
| 311 | |
| 312 | func (err httpError) Error() string { |
| 313 | if err.StatusCode != 422 || len(err.Errors) == 0 { |
| 314 | return fmt.Sprintf("HTTP %d: %s (%s)", err.StatusCode, err.Message, err.RequestURL) |
| 315 | } |
| 316 | query := strings.TrimSpace(err.RequestURL.Query().Get("q")) |
| 317 | return fmt.Sprintf("Invalid search query %q.\n%s", query, err.Errors[0].Message) |
| 318 | } |
| 319 | |
| 320 | // asSearchError converts an api.HTTPError into search's own error type, which formats |
| 321 | // invalid queries differently from the rest of the CLI. |