MCPcopy Create free account
hub / github.com/akash-network/provider / handleHTTPError

Function handleHTTPError

operator/ip/operator.go:436–455  ·  view source on GitHub ↗
(op *ipOperator, rw http.ResponseWriter, req *http.Request, err error, status int)

Source from the content-addressed store, hash-verified

434}
435
436func handleHTTPError(op *ipOperator, rw http.ResponseWriter, req *http.Request, err error, status int) {
437 op.log.Error("http request processing failed", "method", req.Method, "path", req.URL.Path, "err", err)
438 rw.WriteHeader(status)
439
440 body := ipoptypes.IPOperatorErrorResponse{
441 Error: err.Error(),
442 Code: -1,
443 }
444
445 if errors.Is(err, ipoptypes.ErrIPOperator) {
446 code := err.(ipoptypes.IPOperatorError).GetCode()
447 body.Code = code
448 }
449
450 encoder := json.NewEncoder(rw)
451 err = encoder.Encode(body)
452 if err != nil {
453 op.log.Error("failed writing response body", "err", err)
454 }
455}
456
457func newIPOperator(ctx context.Context, logger log.Logger, ns string, cfg common.OperatorConfig, ilc common.IgnoreListConfig, mllbc metallb.Client) (*ipOperator, error) {
458 kc, err := fromctx.KubeClientFromCtx(ctx)

Callers 1

handleIPLeaseStatusGetFunction · 0.85

Calls 2

GetCodeMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected