MCPcopy
hub / github.com/cli/cli / handleError

Function handleError

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

Source from the content-addressed store, hash-verified

1664}
1665
1666func 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
1689var scopesRE = regexp.MustCompile(`one of the following scopes: \[(.+?)]`)
1690

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