Skip to content

Commit

Permalink
remove RespondError()
Browse files Browse the repository at this point in the history
  • Loading branch information
vpranckaitis committed Dec 21, 2020
1 parent 184fb8b commit a050331
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
5 changes: 0 additions & 5 deletions src/query/api/v1/handler/prom/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
9 changes: 5 additions & 4 deletions src/query/api/v1/handler/prom/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand All @@ -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()
Expand All @@ -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
}

Expand Down

0 comments on commit a050331

Please sign in to comment.