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

Function handleResponse

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

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

Callers 7

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

Calls 2

generateScopesSuggestionFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected