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

Function UnexpectedStatusError

api/client.go:295–300  ·  view source on GitHub ↗

UnexpectedStatusError reports a successful response whose status the caller did not expect. The request methods on Client convert every non-2xx response into an HTTPError, so a call site that requires one specific status can only ever be surprised by a different 2xx. Passing such a response to Hand

(resp *http.Response)

Source from the content-addressed store, hash-verified

293// response to HandleHTTPError would ask an error parser to explain a success, so this is used
294// instead. The caller remains responsible for closing the response body stream.
295func UnexpectedStatusError(resp *http.Response) error {
296 if resp.Request != nil {
297 return fmt.Errorf("unexpected HTTP %d for %s %s", resp.StatusCode, resp.Request.Method, resp.Request.URL)
298 }
299 return fmt.Errorf("unexpected HTTP %d", resp.StatusCode)
300}
301
302// handleRequestError converts a request error into an HTTPError or GraphQLError, first adding any
303// endpoint scopes to the error's headers so that the scopes suggestion generated by handleResponse

Callers 12

publishedReleaseExistsFunction · 0.92
GetScopesFunction · 0.92
GetRawGistFileFunction · 0.92
getTopicsFunction · 0.92
setTopicsFunction · 0.92
GetLogMethod · 0.92
getLogFunction · 0.92
fetchDiffFunction · 0.92
repoExistsFunction · 0.92
getLatestReleaseInfoFunction · 0.92
RepoExistsFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by 1