From 4a9cef32ac6aa565d1e92faf72a472e727b205e6 Mon Sep 17 00:00:00 2001 From: vamsi-amazon Date: Fri, 4 Nov 2022 10:47:31 -0700 Subject: [PATCH] Fix error messaging from prometheus. (#1029) Signed-off-by: vamsi-amazon --- .../opensearch/sql/prometheus/client/PrometheusClientImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/prometheus/src/main/java/org/opensearch/sql/prometheus/client/PrometheusClientImpl.java b/prometheus/src/main/java/org/opensearch/sql/prometheus/client/PrometheusClientImpl.java index 4a469c7bbb..512c014564 100644 --- a/prometheus/src/main/java/org/opensearch/sql/prometheus/client/PrometheusClientImpl.java +++ b/prometheus/src/main/java/org/opensearch/sql/prometheus/client/PrometheusClientImpl.java @@ -106,7 +106,8 @@ private JSONObject readResponse(Response response) throws IOException { } } else { throw new RuntimeException( - String.format("Request to Prometheus is Unsuccessful with : %s", response.message())); + String.format("Request to Prometheus is Unsuccessful with : %s", Objects.requireNonNull( + response.body(), "Response body can't be null").string())); } }