QueryEditors: include error when no data is returned (#23632)

This commit is contained in:
Ryan McKinley 2020-04-18 14:59:36 -07:00 committed by GitHub
parent f30074c70a
commit 806dd3f604
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -43,4 +43,17 @@ describe('filterPanelDataToQuery', () => {
expect(panelData?.series[0].refId).toBe('B');
expect(panelData?.error!.refId).toBe('B');
});
it('should include errors when missing data', () => {
const withError = ({
series: [],
error: {
message: 'Error!!',
},
} as unknown) as PanelData;
const panelData = filterPanelDataToQuery(withError, 'B');
expect(panelData.state).toBe(LoadingState.Error);
expect(panelData.error).toBe(withError.error);
});
});

View File

@ -335,6 +335,13 @@ export function filterPanelDataToQuery(data: PanelData, refId: string): PanelDat
// No matching series
if (!series.length) {
// If there was an error with no data, pass it to the QueryEditors
if (data.error && !data.series.length) {
return {
...data,
state: LoadingState.Error,
};
}
return undefined;
}