MCPcopy Create free account
hub / github.com/cloudbase/garm / parseError

Function parseError

util/github/client.go:266–305  ·  view source on GitHub ↗
(response *github.Response, err error)

Source from the content-addressed store, hash-verified

264}
265
266func parseError(response *github.Response, err error) error {
267 var statusCode int
268 if response != nil {
269 statusCode = response.StatusCode
270 }
271
272 switch statusCode {
273 case http.StatusNotFound:
274 return runnerErrors.ErrNotFound
275 case http.StatusUnauthorized:
276 return runnerErrors.ErrUnauthorized
277 case http.StatusUnprocessableEntity:
278 return runnerErrors.ErrBadRequest
279 default:
280 if statusCode >= 100 && statusCode < 300 {
281 return nil
282 }
283 if err != nil {
284 errResp := &github.ErrorResponse{}
285 if errors.As(err, &errResp) && errResp.Response != nil {
286 switch errResp.Response.StatusCode {
287 case http.StatusNotFound:
288 return runnerErrors.ErrNotFound
289 case http.StatusUnauthorized:
290 return runnerErrors.ErrUnauthorized
291 case http.StatusUnprocessableEntity:
292 return runnerErrors.ErrBadRequest
293 default:
294 // ugly hack. Gitea returns 500 if we try to remove a runner that does not exist.
295 if strings.Contains(err.Error(), "does not exist") {
296 return runnerErrors.ErrNotFound
297 }
298 return err
299 }
300 }
301 return err
302 }
303 return errors.New("unknown error")
304 }
305}
306
307func (g *githubClient) RemoveEntityRunner(ctx context.Context, runnerID int64) error {
308 var response *github.Response

Callers 2

RemoveEntityRunnerMethod · 0.85
RateLimitMethod · 0.85

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected