newAPIResponseError turns non-2xx `auth0 api` responses into SDK management errors. This keeps `error_class` handling consistent with typed SDK commands.
(statusCode int, header http.Header, body []byte)
| 287 | // newAPIResponseError turns non-2xx `auth0 api` responses into SDK management errors. |
| 288 | // This keeps `error_class` handling consistent with typed SDK commands. |
| 289 | func newAPIResponseError(statusCode int, header http.Header, body []byte) error { |
| 290 | message := strings.TrimSpace(string(body)) |
| 291 | if message == "" { |
| 292 | message = http.StatusText(statusCode) |
| 293 | } |
| 294 | |
| 295 | return core.NewAPIError(statusCode, header, fmt.Errorf("API request failed: %s", message)) |
| 296 | } |
| 297 | |
| 298 | func isInsufficientScopeError(r *http.Response) error { |
| 299 | if r.StatusCode != 403 { |