ExtractError returns the response wrapped inside an APIError.
(resp *http.Response)
| 39 | |
| 40 | // ExtractError returns the response wrapped inside an APIError. |
| 41 | func ExtractError(resp *http.Response) APIError { |
| 42 | body, _ := io.ReadAll(resp.Body) |
| 43 | |
| 44 | return APIError{ |
| 45 | Response: resp, |
| 46 | Body: body, |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | // GetError reports whether the given "err" is an APIError. |
| 51 | func GetError(err error) (APIError, bool) { |