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

Function handleResponse

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

316// handleResponse takes a ghAPI.HTTPError or ghAPI.GraphQLError and converts it into an
317// HTTPError or GraphQLError respectively.
318func handleResponse(err error) error {
319 if err == nil {
320 return nil
321 }
322
323 var restErr *ghAPI.HTTPError
324 if errors.As(err, &restErr) {
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 var gqlErr *ghAPI.GraphQLError
335 if errors.As(err, &gqlErr) {
336 return GraphQLError{
337 GraphQLError: gqlErr,
338 }
339 }
340
341 return err
342}
343
344// ScopesSuggestion is an error messaging utility that prints the suggestion to request additional OAuth
345// 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