Skip to content

Commit

Permalink
Dashboards: Show error when data source is missing (#60099)
Browse files Browse the repository at this point in the history
Return caught exceptions to panel as error state

(cherry picked from commit 9a41277)
  • Loading branch information
joshhunt authored and grafanabot committed Dec 14, 2022
1 parent 21c1d14 commit e3ce69e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/grafana-runtime/src/utils/toDataQueryError.ts
Expand Up @@ -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) {
Expand Down
12 changes: 10 additions & 2 deletions public/app/features/query/state/PanelQueryRunner.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -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
);
}
}

Expand Down

0 comments on commit e3ce69e

Please sign in to comment.