Variable: Inform users of the error details when Grafana is unable to retrieve the variable values from an SQL data source. (#82222)

* feat: Inform users of the error details when Grafana is unable to retrieve the variable values from an SQL data source.

* format code

* use getAppEvents

* throw an error when failing to executing the sql query

* optimize code

* prettier
This commit is contained in:
Faye Lin
2024-02-12 19:19:22 +08:00
committed by GitHub
parent 70fc603d26
commit a3f3429290

View File

@ -208,7 +208,13 @@ export abstract class SqlDatasource extends DataSourceWithBackend<SQLQuery, SQLO
format: QueryFormat.Table,
};
const response = await this.runMetaQuery(interpolatedQuery, range);
let response;
try {
response = await this.runMetaQuery(interpolatedQuery, range);
} catch (error) {
console.error(error);
throw new Error('error when executing the sql query');
}
return this.getResponseParser().transformMetricFindResponse(response);
}