[v9.3.x] Dashboards: Show error when data source is missing (#60313)

Dashboards: Show error when data source is missing (#60099)

Return caught exceptions to panel as error state

(cherry picked from commit 9a41277ecd)

Co-authored-by: Josh Hunt <joshhunt@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2022-12-14 07:51:04 -05:00
committed by GitHub
co-authored by Josh Hunt
parent 21c1d14e91
commit b297cbfc06
2 changed files with 11 additions and 3 deletions
@@ -6,7 +6,7 @@ import { DataQueryError } from '@grafana/data';
*
* @public
*/
export function toDataQueryError(err: DataQueryError | string | Object): DataQueryError {
export function toDataQueryError(err: DataQueryError | string | unknown): DataQueryError {
const error = (err || {}) as DataQueryError;
if (!error.message) {
@@ -25,7 +25,7 @@ import {
toDataFrame,
transformDataFrame,
} from '@grafana/data';
import { getTemplateSrv } from '@grafana/runtime';
import { getTemplateSrv, toDataQueryError } from '@grafana/runtime';
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
import { StreamingDataFrame } from 'app/features/live/data/StreamingDataFrame';
import { isStreamingDataFrame } from 'app/features/live/data/utils';
@@ -274,7 +274,15 @@ export class PanelQueryRunner {
this.pipeToSubject(runRequest(ds, request), panelId);
} catch (err) {
console.error('PanelQueryRunner Error', err);
this.pipeToSubject(
of({
state: LoadingState.Error,
error: toDataQueryError(err),
series: [],
timeRange: request.range,
}),
panelId
);
}
}