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