(statusCode int, rate *Rate, body io.Reader)
| 410 | } |
| 411 | |
| 412 | func (c *Client) makeStreamError(statusCode int, rate *Rate, body io.Reader) error { |
| 413 | if body == nil { |
| 414 | return errors.New("invalid body") |
| 415 | } |
| 416 | errBody, err := io.ReadAll(body) |
| 417 | if err != nil { |
| 418 | return err |
| 419 | } |
| 420 | var streamErr APIError |
| 421 | if err := json.Unmarshal(errBody, &streamErr); err != nil { |
| 422 | return fmt.Errorf("unexpected error (status code %d)", statusCode) |
| 423 | } |
| 424 | streamErr.StatusCode = statusCode |
| 425 | streamErr.Rate = rate |
| 426 | return streamErr |
| 427 | } |
| 428 | |
| 429 | type endpoint struct { |
| 430 | url *url.URL |
no outgoing calls