managementHTTPStatus extracts the HTTP status from a go-auth0 management API error anywhere in the error chain, supporting both the v1 (management.Error) and v2 (*core.APIError) SDK error types.
(err error)
| 374 | // error anywhere in the error chain, supporting both the v1 (management.Error) |
| 375 | // and v2 (*core.APIError) SDK error types. |
| 376 | func managementHTTPStatus(err error) (int, bool) { |
| 377 | var v1 management.Error |
| 378 | if errors.As(err, &v1) { |
| 379 | return v1.Status(), true |
| 380 | } |
| 381 | |
| 382 | var v2 *core.APIError |
| 383 | if errors.As(err, &v2) { |
| 384 | return v2.StatusCode, true |
| 385 | } |
| 386 | |
| 387 | return 0, false |
| 388 | } |
| 389 | |
| 390 | func errorClassForHTTPStatus(status int) string { |
| 391 | switch { |
no test coverage detected