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

Function handleError

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

Source from the content-addressed store, hash-verified

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

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