From 43a1cb25b93f67cc29fc71d4c009e33126722b2f Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Sat, 24 Oct 2020 05:23:42 +0530 Subject: [PATCH] Elasticsearch: Fix handling of errors when testing data source (#28498) (#28504) #24999 changed the error response payload, but the test data source was not adapted to this change and broke the feature of displaying any errors to the user in the UI. This change should resolve this problem. Ref #24999 Ref #28481 (cherry picked from commit c8b7ccc66caf68559e7603f6472ea23bc7e65eaf) Co-authored-by: Marcus Efraimsson --- public/app/plugins/datasource/elasticsearch/datasource.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/datasource.ts b/public/app/plugins/datasource/elasticsearch/datasource.ts index 1dacb53ec5b..3697892927d 100644 --- a/public/app/plugins/datasource/elasticsearch/datasource.ts +++ b/public/app/plugins/datasource/elasticsearch/datasource.ts @@ -338,12 +338,8 @@ export class ElasticDatasource extends DataSourceApi { console.error(err); - if (err.data && err.data.error) { - let message = angular.toJson(err.data.error); - if (err.data.error.reason) { - message = err.data.error.reason; - } - return { status: 'error', message: message }; + if (err.message) { + return { status: 'error', message: err.message }; } else { return { status: 'error', message: err.status }; }