MCPcopy Create free account
hub / github.com/auth0/auth0-cli / newAPIResponseError

Function newAPIResponseError

internal/cli/api.go:289–296  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

287// newAPIResponseError turns non-2xx `auth0 api` responses into SDK management errors.
288// This keeps `error_class` handling consistent with typed SDK commands.
289func 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
298func isInsufficientScopeError(r *http.Response) error {
299 if r.StatusCode != 403 {

Callers 1

apiCmdRunFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected