MCPcopy
hub / github.com/prometheus/prometheus / returnAPIError

Function returnAPIError

web/api/v1/api.go:751–773  ·  view source on GitHub ↗
(err error)

Source from the content-addressed store, hash-verified

749}
750
751func returnAPIError(err error) *apiError {
752 if err == nil {
753 return nil
754 }
755
756 var eqc promql.ErrQueryCanceled
757 var eqt promql.ErrQueryTimeout
758 var es promql.ErrStorage
759 switch {
760 case errors.As(err, &eqc):
761 return &apiError{errorCanceled, err}
762 case errors.As(err, &eqt):
763 return &apiError{errorTimeout, err}
764 case errors.As(err, &es):
765 return &apiError{errorInternal, err}
766 }
767
768 if errors.Is(err, context.Canceled) {
769 return &apiError{errorCanceled, err}
770 }
771
772 return &apiError{errorExec, err}
773}
774
775func (api *API) labelNames(r *http.Request) apiFuncResult {
776 limit, err := parseLimitParam(r.FormValue("limit"))

Callers 7

queryMethod · 0.85
queryRangeMethod · 0.85
queryExemplarsMethod · 0.85
labelNamesMethod · 0.85
seriesMethod · 0.85
searchAPIErrorFunction · 0.85
TestReturnAPIErrorFunction · 0.85

Calls 1

IsMethod · 0.45

Tested by 1

TestReturnAPIErrorFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…