MCPcopy
hub / github.com/cli/cli / handleResponse

Function handleResponse

api/client.go:164–188  ·  view source on GitHub ↗

handleResponse takes a ghAPI.HTTPError or ghAPI.GraphQLError and converts it into an HTTPError or GraphQLError respectively.

(err error)

Source from the content-addressed store, hash-verified

162// handleResponse takes a ghAPI.HTTPError or ghAPI.GraphQLError and converts it into an
163// HTTPError or GraphQLError respectively.
164func handleResponse(err error) error {
165 if err == nil {
166 return nil
167 }
168
169 var restErr *ghAPI.HTTPError
170 if errors.As(err, &restErr) {
171 return HTTPError{
172 HTTPError: restErr,
173 scopesSuggestion: generateScopesSuggestion(restErr.StatusCode,
174 restErr.Headers.Get("X-Accepted-Oauth-Scopes"),
175 restErr.Headers.Get("X-Oauth-Scopes"),
176 restErr.RequestURL.Hostname()),
177 }
178 }
179
180 var gqlErr *ghAPI.GraphQLError
181 if errors.As(err, &gqlErr) {
182 return GraphQLError{
183 GraphQLError: gqlErr,
184 }
185 }
186
187 return err
188}
189
190// ScopesSuggestion is an error messaging utility that prints the suggestion to request additional OAuth
191// scopes in case a server response indicates that there are missing scopes.

Callers 6

GraphQLMethod · 0.85
MutateMethod · 0.85
QueryMethod · 0.85
QueryWithContextMethod · 0.85
RESTMethod · 0.85
HandleHTTPErrorFunction · 0.85

Calls 2

generateScopesSuggestionFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected