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

Function handleResponse

api/client.go:319–341  ·  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

317// handleResponse takes a ghAPI.HTTPError or ghAPI.GraphQLError and converts it into an
318// HTTPError or GraphQLError respectively.
319func handleResponse(err error) error {
320 if err == nil {
321 return nil
322 }
323
324 if restErr, ok := errors.AsType[*ghAPI.HTTPError](err); ok {
325 return HTTPError{
326 HTTPError: restErr,
327 scopesSuggestion: generateScopesSuggestion(restErr.StatusCode,
328 restErr.Headers.Get("X-Accepted-Oauth-Scopes"),
329 restErr.Headers.Get("X-Oauth-Scopes"),
330 restErr.RequestURL.Hostname()),
331 }
332 }
333
334 if gqlErr, ok := errors.AsType[*ghAPI.GraphQLError](err); ok {
335 return GraphQLError{
336 GraphQLError: gqlErr,
337 }
338 }
339
340 return err
341}
342
343// ScopesSuggestion is an error messaging utility that prints the suggestion to request additional OAuth
344// scopes in case a server response indicates that there are missing scopes.

Callers 8

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

Calls 2

generateScopesSuggestionFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected