(err error)
| 1711 | } |
| 1712 | |
| 1713 | func handleError(err error) error { |
| 1714 | var gerr api.GraphQLError |
| 1715 | if errors.As(err, &gerr) { |
| 1716 | missing := set.NewStringSet() |
| 1717 | for _, e := range gerr.Errors { |
| 1718 | if e.Type != "INSUFFICIENT_SCOPES" { |
| 1719 | continue |
| 1720 | } |
| 1721 | missing.AddValues(requiredScopesFromServerMessage(e.Message)) |
| 1722 | } |
| 1723 | if missing.Len() > 0 { |
| 1724 | s := missing.ToSlice() |
| 1725 | // TODO: this duplicates parts of generateScopesSuggestion |
| 1726 | return fmt.Errorf( |
| 1727 | "error: your authentication token is missing required scopes %v\n"+ |
| 1728 | "To request it, run: gh auth refresh -s %s", |
| 1729 | s, |
| 1730 | strings.Join(s, ",")) |
| 1731 | } |
| 1732 | } |
| 1733 | return err |
| 1734 | } |
| 1735 | |
| 1736 | var scopesRE = regexp.MustCompile(`one of the following scopes: \[(.+?)]`) |
| 1737 |
no test coverage detected