From 8cb7769e36f9763547a38da7dcf08ddfebe78801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Carvalho?= Date: Fri, 31 Mar 2017 21:05:08 -0300 Subject: [PATCH] api: stops ignoring errors creating requests --- api/prometheus/api.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/api/prometheus/api.go b/api/prometheus/api.go index d2b30b6..29eed5d 100644 --- a/api/prometheus/api.go +++ b/api/prometheus/api.go @@ -306,7 +306,10 @@ func (h *httpQueryAPI) Query(ctx context.Context, query string, ts time.Time) (m u.RawQuery = q.Encode() - req, _ := http.NewRequest("GET", u.String(), nil) + req, err := http.NewRequest("GET", u.String(), nil) + if err != nil { + return nil, err + } _, body, err := h.client.do(ctx, req) if err != nil { @@ -336,7 +339,10 @@ func (h *httpQueryAPI) QueryRange(ctx context.Context, query string, r Range) (m u.RawQuery = q.Encode() - req, _ := http.NewRequest("GET", u.String(), nil) + req, err := http.NewRequest("GET", u.String(), nil) + if err != nil { + return nil, err + } _, body, err := h.client.do(ctx, req) if err != nil { @@ -351,7 +357,10 @@ func (h *httpQueryAPI) QueryRange(ctx context.Context, query string, r Range) (m func (h *httpQueryAPI) QueryLabelValues(ctx context.Context, label string) ([]string, error) { u := h.client.url(epLabelValues, map[string]string{"name": label}) - req, _ := http.NewRequest(http.MethodGet, u.String(), nil) + req, err := http.NewRequest(http.MethodGet, u.String(), nil) + if err != nil { + return nil, err + } _, body, err := h.client.do(ctx, req) if err != nil { return nil, err