mirror of
https://github.com/grafana/grafana.git
synced 2025-01-08 15:13:30 -06:00
PanelQueryRunner: move error handling to QueryRunnerOptions (#16654)
This commit is contained in:
parent
ed0192104c
commit
f4cd9bc73c
@ -99,15 +99,9 @@ export class PanelChrome extends PureComponent<Props, State> {
|
||||
if (data.state === LoadingState.Error) {
|
||||
const { error } = data;
|
||||
if (error) {
|
||||
let message = 'Query error';
|
||||
if (error.message) {
|
||||
message = error.message;
|
||||
} else if (error.data && error.data.message) {
|
||||
message = error.data.message;
|
||||
} else if (error.data && error.data.error) {
|
||||
message = error.data.error;
|
||||
} else if (error.status) {
|
||||
message = `Query error: ${error.status} ${error.statusText}`;
|
||||
let message = error.message;
|
||||
if (!message) {
|
||||
message = 'Query error';
|
||||
}
|
||||
|
||||
if (this.state.errorMessage !== message) {
|
||||
|
@ -20,10 +20,10 @@ import cloneDeep from 'lodash/cloneDeep';
|
||||
|
||||
import kbn from 'app/core/utils/kbn';
|
||||
|
||||
export interface QueryRunnerOptions {
|
||||
ds?: DataSourceApi; // if they already have the datasource, don't look it up
|
||||
export interface QueryRunnerOptions<TQuery extends DataQuery = DataQuery> {
|
||||
ds?: DataSourceApi<TQuery>; // if they already have the datasource, don't look it up
|
||||
datasource: string | null;
|
||||
queries: DataQuery[];
|
||||
queries: TQuery[];
|
||||
panelId: number;
|
||||
dashboardId?: number;
|
||||
timezone?: string;
|
||||
@ -174,7 +174,17 @@ export class PanelQueryRunner {
|
||||
} catch (err) {
|
||||
const error = err as DataQueryError;
|
||||
if (!error.message) {
|
||||
err.message = 'Query Error';
|
||||
let message = 'Query error';
|
||||
if (error.message) {
|
||||
message = error.message;
|
||||
} else if (error.data && error.data.message) {
|
||||
message = error.data.message;
|
||||
} else if (error.data && error.data.error) {
|
||||
message = error.data.error;
|
||||
} else if (error.status) {
|
||||
message = `Query error: ${error.status} ${error.statusText}`;
|
||||
}
|
||||
error.message = message;
|
||||
}
|
||||
|
||||
this.data = {
|
||||
|
Loading…
Reference in New Issue
Block a user