mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Datasources: Improve error handling for testing data sources (#35120)
* Improve error handling for error messages The error message will be read from error object from the following properties in the following order: - message - data.message - statusText * Convert api/ds/query errors to TestingStatus SQL datasources (mysql, mssql, postgres) and CloudWatch use api/ds/query to test the data source, but previously didn't handle errors returned by this endpoint. If the error cannot be handled it's re-thrown to be handled in public/app/features/datasources/state/actions.ts * Use async/await instead of Promises * Remove incorrect type import TestingStatus is in app/types. Should be pulled down to grafana/data but it depends on HealthCheckResultDetails that is public and lives in grafana/runtime. Ideally TestingStatus should live in grafana/data but I'm not sure if HealthCheckResultDetails can be move there too (?) * Update packages/grafana-data/src/types/datasource.ts Co-authored-by: Erik Sundell <erik.sundell@grafana.com> * Handle errors with no details in toTestingStatus instead of re-throwing * Update packages/grafana-data/src/types/datasource.ts Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com> Co-authored-by: Erik Sundell <erik.sundell@grafana.com> Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
This commit is contained in:
@@ -228,7 +228,11 @@ abstract class DataSourceApi<
|
||||
abstract query(request: DataQueryRequest<TQuery>): Promise<DataQueryResponse> | Observable<DataQueryResponse>;
|
||||
|
||||
/**
|
||||
* Test & verify datasource settings & connection details
|
||||
* Test & verify datasource settings & connection details (returning TestingStatus)
|
||||
*
|
||||
* When verification fails - errors specific to the data source should be handled here and converted to
|
||||
* a TestingStatus object. Unknown errors and HTTP errors can be re-thrown and will be handled here:
|
||||
* public/app/features/datasources/state/actions.ts
|
||||
*/
|
||||
abstract testDatasource(): Promise<any>;
|
||||
|
||||
@@ -472,7 +476,13 @@ export enum DataQueryErrorType {
|
||||
|
||||
export interface DataQueryError {
|
||||
data?: {
|
||||
/**
|
||||
* Short information about the error
|
||||
*/
|
||||
message?: string;
|
||||
/**
|
||||
* Detailed information about the error. Only returned when app_mode is development.
|
||||
*/
|
||||
error?: string;
|
||||
};
|
||||
message?: string;
|
||||
|
||||
Reference in New Issue
Block a user