From a4c7cf78659fba9c4675c74186b138fefd791ebe Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Mon, 7 Nov 2022 10:01:21 -0800 Subject: [PATCH] Fix error messaging from prometheus. (#1029) (#1037) Signed-off-by: vamsi-amazon (cherry picked from commit 4a9cef32ac6aa565d1e92faf72a472e727b205e6) Co-authored-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())); } }