(err error)
| 1664 | } |
| 1665 | |
| 1666 | func handleError(err error) error { |
| 1667 | var gerr api.GraphQLError |
| 1668 | if errors.As(err, &gerr) { |
| 1669 | missing := set.NewStringSet() |
| 1670 | for _, e := range gerr.Errors { |
| 1671 | if e.Type != "INSUFFICIENT_SCOPES" { |
| 1672 | continue |
| 1673 | } |
| 1674 | missing.AddValues(requiredScopesFromServerMessage(e.Message)) |
| 1675 | } |
| 1676 | if missing.Len() > 0 { |
| 1677 | s := missing.ToSlice() |
| 1678 | // TODO: this duplicates parts of generateScopesSuggestion |
| 1679 | return fmt.Errorf( |
| 1680 | "error: your authentication token is missing required scopes %v\n"+ |
| 1681 | "To request it, run: gh auth refresh -s %s", |
| 1682 | s, |
| 1683 | strings.Join(s, ",")) |
| 1684 | } |
| 1685 | } |
| 1686 | return err |
| 1687 | } |
| 1688 | |
| 1689 | var scopesRE = regexp.MustCompile(`one of the following scopes: \[(.+?)]`) |
| 1690 |
no test coverage detected