diff --git a/prometheus/promhttp/http.go b/prometheus/promhttp/http.go index 4c70a7a..2d67f24 100644 --- a/prometheus/promhttp/http.go +++ b/prometheus/promhttp/http.go @@ -128,7 +128,7 @@ func HandlerFor(reg prometheus.Gatherer, opts HandlerOpts) http.Handler { closer.Close() } if lastErr != nil && buf.Len() == 0 { - http.Error(w, "No metrics encoded, last error:\n\n"+err.Error(), http.StatusInternalServerError) + http.Error(w, "No metrics encoded, last error:\n\n"+lastErr.Error(), http.StatusInternalServerError) return } header := w.Header()