| 347 | } |
| 348 | |
| 349 | func classifyCommandFailure(err error) map[string]string { |
| 350 | properties := map[string]string{ |
| 351 | "success": "false", |
| 352 | "error_class": "unknown", |
| 353 | } |
| 354 | |
| 355 | if errors.Is(err, config.ErrInvalidToken) || errors.Is(err, config.ErrMalformedToken) { |
| 356 | properties["error_class"] = "auth" |
| 357 | return properties |
| 358 | } |
| 359 | |
| 360 | var missingScopesErr config.ErrTokenMissingRequiredScopes |
| 361 | if errors.As(err, &missingScopesErr) { |
| 362 | properties["error_class"] = "auth" |
| 363 | return properties |
| 364 | } |
| 365 | |
| 366 | if status, ok := managementHTTPStatus(err); ok { |
| 367 | properties["error_class"] = errorClassForHTTPStatus(status) |
| 368 | } |
| 369 | |
| 370 | return properties |
| 371 | } |
| 372 | |
| 373 | // managementHTTPStatus extracts the HTTP status from a go-auth0 management API |
| 374 | // error anywhere in the error chain, supporting both the v1 (management.Error) |