Elasticsearch: Update error message shown when testing the datasource (#70189)

* Elasticsearch: update error message shown when testing the datasource

* Elasticsearch: update successful test message

* Update e2e test
This commit is contained in:
Matias Chomicki
2023-06-16 12:56:34 +02:00
committed by GitHub
parent 5fc6bf5c69
commit 6e2c811fd8
3 changed files with 6 additions and 9 deletions

View File

@@ -75,7 +75,7 @@ export class LegacyQueryRunner {
const message = err.data.error?.reason ?? err.data.message ?? 'Unknown error'; const message = err.data.error?.reason ?? err.data.message ?? 'Unknown error';
return throwError({ return throwError({
message: 'Elasticsearch error: ' + message, message,
error: err.data.error, error: err.data.error,
}); });
} }

View File

@@ -505,7 +505,7 @@ describe('ElasticDatasource', () => {
const errObject = { const errObject = {
error: 'Bad Request', error: 'Bad Request',
message: 'Elasticsearch error: Authentication to data source failed', message: 'Authentication to data source failed',
}; };
await expect(ds.query(query)).toEmitValuesWith((received) => { await expect(ds.query(query)).toEmitValuesWith((received) => {

View File

@@ -426,15 +426,12 @@ export class ElasticDatasource
message: 'No date field named ' + this.timeField + ' found', message: 'No date field named ' + this.timeField + ' found',
}); });
} }
return of({ status: 'success', message: `${versionMessage}Index OK. Time field name OK` }); return of({ status: 'success', message: `${versionMessage}Data source successfully connected.` });
}), }),
catchError((err) => { catchError((err) => {
console.error(err); const infoInParentheses = err.message ? ` (${err.message})` : '';
if (err.message) { const message = `Unable to connect with Elasticsearch${infoInParentheses}. Please check the server logs for more details.`;
return of({ status: 'error', message: err.message }); return of({ status: 'error', message });
} else {
return of({ status: 'error', message: err.status });
}
}) })
) )
); );