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

Function handleResponse

api/client.go:318–340  ·  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 if restErr, ok := errors.AsType[*ghAPI.HTTPError](err); ok {
324 return HTTPError{
325 HTTPError: restErr,
326 scopesSuggestion: generateScopesSuggestion(restErr.StatusCode,
327 restErr.Headers.Get("X-Accepted-Oauth-Scopes"),
328 restErr.Headers.Get("X-Oauth-Scopes"),
329 restErr.RequestURL.Hostname()),
330 }
331 }
332
333 if gqlErr, ok := errors.AsType[*ghAPI.GraphQLError](err); ok {
334 return GraphQLError{
335 GraphQLError: gqlErr,
336 }
337 }
338
339 return err
340}
341
342// ScopesSuggestion is an error messaging utility that prints the suggestion to request additional OAuth
343// 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