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

Return caught exceptions to panel as error state
This commit is contained in:
Josh Hunt 2022-12-14 12:37:31 +00:00 committed by GitHub
parent 666f69ca14
commit 9a41277ecd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -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) {

View File

@ -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';
@ -276,7 +276,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
);
}
}