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

Function handleHTTPError

pkg/search/searcher.go:300–317  ·  view source on GitHub ↗
(resp *http.Response)

Source from the content-addressed store, hash-verified

298}
299
300func handleHTTPError(resp *http.Response) error {
301 httpError := httpError{
302 RequestURL: resp.Request.URL,
303 StatusCode: resp.StatusCode,
304 }
305 if !jsonTypeRE.MatchString(resp.Header.Get("Content-Type")) {
306 httpError.Message = resp.Status
307 return httpError
308 }
309 body, err := io.ReadAll(resp.Body)
310 if err != nil {
311 return err
312 }
313 if err := json.Unmarshal(body, &httpError); err != nil {
314 return err
315 }
316 return httpError
317}
318
319// nextPage extracts the next page number from an API response's link header. if
320// the provided link header is empty or there is no next page, zero is returned.

Callers 1

searchMethod · 0.85

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected