Commit f4cd9bc7 by Ryan McKinley Committed by Torkel Ödegaard

PanelQueryRunner: move error handling to QueryRunnerOptions (#16654)

parent ed019210
......@@ -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 = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment