From aad558ce9cd36ad4dc962180fb47930d9520d647 Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Wed, 13 Feb 2019 15:54:10 +0100 Subject: [PATCH] using error callback from datapanel instead --- .../grafana-ui/src/components/Tooltip/Popper.tsx | 12 ++++++++++-- public/app/features/dashboard/dashgrid/DataPanel.tsx | 7 +++++-- .../app/features/dashboard/dashgrid/PanelChrome.tsx | 5 +++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/grafana-ui/src/components/Tooltip/Popper.tsx b/packages/grafana-ui/src/components/Tooltip/Popper.tsx index 90cfc2619e8..cf4b9cdd653 100644 --- a/packages/grafana-ui/src/components/Tooltip/Popper.tsx +++ b/packages/grafana-ui/src/components/Tooltip/Popper.tsx @@ -35,8 +35,16 @@ interface Props extends React.HTMLAttributes { class Popper extends PureComponent { render() { - const { show, placement, onMouseEnter, onMouseLeave, className, wrapperClassName, renderArrow } = this.props; - const { content } = this.props; + const { + content, + show, + placement, + onMouseEnter, + onMouseLeave, + className, + wrapperClassName, + renderArrow, + } = this.props; return ( diff --git a/public/app/features/dashboard/dashgrid/DataPanel.tsx b/public/app/features/dashboard/dashgrid/DataPanel.tsx index 80c49b15494..75c931ec14e 100644 --- a/public/app/features/dashboard/dashgrid/DataPanel.tsx +++ b/public/app/features/dashboard/dashgrid/DataPanel.tsx @@ -34,6 +34,7 @@ export interface Props { maxDataPoints?: number; children: (r: RenderProps) => JSX.Element; onDataResponse?: (data: DataQueryResponse) => void; + onError: (errorMessage: string) => void; } export interface State { @@ -94,6 +95,7 @@ export class DataPanel extends Component { widthPixels, maxDataPoints, onDataResponse, + onError, } = this.props; if (!isVisible) { @@ -146,7 +148,9 @@ export class DataPanel extends Component { } catch (err) { console.log('Loading error', err); this.setState({ isFirstLoad: false }); - throw new Error('Request Error'); + onError(`Query error + status: ${err.status} + message: ${err.statusText}`); } }; @@ -169,7 +173,6 @@ export class DataPanel extends Component { render() { const { queries } = this.props; const { loading, isFirstLoad } = this.state; - const panelData = this.getPanelData(); if (isFirstLoad && loading === LoadingState.Loading) { diff --git a/public/app/features/dashboard/dashgrid/PanelChrome.tsx b/public/app/features/dashboard/dashgrid/PanelChrome.tsx index d61e5266790..44028f59518 100644 --- a/public/app/features/dashboard/dashgrid/PanelChrome.tsx +++ b/public/app/features/dashboard/dashgrid/PanelChrome.tsx @@ -171,6 +171,7 @@ export class PanelChrome extends PureComponent { widthPixels={width} refreshCounter={refreshCounter} onDataResponse={this.onDataResponse} + onError={this.onError} > {({ loading, panelData }) => { return this.renderPanelPlugin(loading, panelData, width, height); @@ -185,7 +186,7 @@ export class PanelChrome extends PureComponent { render() { const { dashboard, panel } = this.props; - const { timeInfo } = this.state; + const { errorMessage, timeInfo } = this.state; const { transparent } = panel; const containerClassNames = `panel-container panel-container--absolute ${transparent ? 'panel-transparent' : ''}`; @@ -206,7 +207,7 @@ export class PanelChrome extends PureComponent { description={panel.description} scopedVars={panel.scopedVars} links={panel.links} - error={this.state.errorMessage} + error={errorMessage} /> {({ error, errorInfo }) => {