From a0503313f67b4ea81e01714a2940eeeba8f61e4b Mon Sep 17 00:00:00 2001 From: Vilius Pranckaitis Date: Mon, 21 Dec 2020 17:00:43 +0200 Subject: [PATCH] remove RespondError() --- src/query/api/v1/handler/prom/common.go | 5 ----- src/query/api/v1/handler/prom/read.go | 9 +++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/query/api/v1/handler/prom/common.go b/src/query/api/v1/handler/prom/common.go index 3cc3ea74ee..7ef1d039a1 100644 --- a/src/query/api/v1/handler/prom/common.go +++ b/src/query/api/v1/handler/prom/common.go @@ -89,8 +89,3 @@ func Respond(w http.ResponseWriter, data interface{}, warnings promstorage.Warni w.WriteHeader(http.StatusOK) w.Write(b) } - -// Responds with error status code and writes error JSON to response body. -func RespondError(w http.ResponseWriter, err error) { - xhttp.WriteError(w, err) -} diff --git a/src/query/api/v1/handler/prom/read.go b/src/query/api/v1/handler/prom/read.go index b69cdecc39..7b89fcbf67 100644 --- a/src/query/api/v1/handler/prom/read.go +++ b/src/query/api/v1/handler/prom/read.go @@ -34,6 +34,7 @@ import ( "github.com/m3db/m3/src/query/models" "github.com/m3db/m3/src/query/storage/prometheus" xerrors "github.com/m3db/m3/src/x/errors" + xhttp "github.com/m3db/m3/src/x/net/http" "github.com/prometheus/prometheus/promql" promstorage "github.com/prometheus/prometheus/storage" @@ -99,13 +100,13 @@ func (h *readHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { fetchOptions, err := h.hOpts.FetchOptionsBuilder().NewFetchOptions(r) if err != nil { - RespondError(w, err) + xhttp.WriteError(w, err) return } request, err := native.ParseRequest(ctx, r, h.opts.instant, h.hOpts) if err != nil { - RespondError(w, err) + xhttp.WriteError(w, err) return } @@ -129,7 +130,7 @@ func (h *readHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { h.logger.Error("error creating query", zap.Error(err), zap.String("query", params.Query), zap.Bool("instant", h.opts.instant)) - RespondError(w, xerrors.NewInvalidParamsError(err)) + xhttp.WriteError(w, xerrors.NewInvalidParamsError(err)) return } defer qry.Close() @@ -139,7 +140,7 @@ func (h *readHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { h.logger.Error("error executing query", zap.Error(res.Err), zap.String("query", params.Query), zap.Bool("instant", h.opts.instant)) - RespondError(w, res.Err) + xhttp.WriteError(w, res.Err) return }