MCPcopy Create free account
hub / github.com/cli/cli / handleError

Function handleError

pkg/cmd/project/shared/queries/queries.go:1704–1725  ·  view source on GitHub ↗
(err error)

Source from the content-addressed store, hash-verified

1702}
1703
1704func 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
1727var scopesRE = regexp.MustCompile(`one of the following scopes: \[(.+?)]`)
1728

Callers 3

MutateMethod · 0.85
QueryMethod · 0.85

Calls 7

NewStringSetFunction · 0.92
AddValuesMethod · 0.80
JoinMethod · 0.80
LenMethod · 0.65
ToSliceMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected