(err error)
| 560 | } |
| 561 | |
| 562 | func dropboxAPIJSONErrorCode(err error) string { |
| 563 | var rateLimitErr dropboxauth.RateLimitAPIError |
| 564 | var rateLimitErrPtr *dropboxauth.RateLimitAPIError |
| 565 | if errors.As(err, &rateLimitErr) || errors.As(err, &rateLimitErrPtr) { |
| 566 | return jsonErrorCodeRateLimited |
| 567 | } |
| 568 | |
| 569 | var authErr dropboxauth.AuthAPIError |
| 570 | var authErrPtr *dropboxauth.AuthAPIError |
| 571 | if errors.As(err, &authErr) { |
| 572 | return dropboxAuthAPIErrorCode(authErr.AuthError) |
| 573 | } |
| 574 | if errors.As(err, &authErrPtr) { |
| 575 | if authErrPtr == nil { |
| 576 | return jsonErrorCodeDropboxAPIError |
| 577 | } |
| 578 | return dropboxAuthAPIErrorCode(authErrPtr.AuthError) |
| 579 | } |
| 580 | |
| 581 | var accessErr dropboxauth.AccessAPIError |
| 582 | var accessErrPtr *dropboxauth.AccessAPIError |
| 583 | if errors.As(err, &accessErr) || errors.As(err, &accessErrPtr) { |
| 584 | return jsonErrorCodePermissionDenied |
| 585 | } |
| 586 | |
| 587 | if summary, ok := dropboxAPIErrorSummary(err); ok { |
| 588 | if code := dropboxAPIMessageErrorCode(summary); code != "" { |
| 589 | return code |
| 590 | } |
| 591 | return jsonErrorCodeDropboxAPIError |
| 592 | } |
| 593 | if summary, ok := dropboxAPISummaryFromMessage(err.Error()); ok { |
| 594 | return dropboxAPIMessageErrorCode(summary) |
| 595 | } |
| 596 | return "" |
| 597 | } |
| 598 | |
| 599 | func dropboxAuthAPIErrorCode(authErr *dropboxauth.AuthError) string { |
| 600 | if authErr == nil { |
no test coverage detected