mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Error Handling: support errors and data in a response (#20169)
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
MetricFindValue,
|
||||
TableData,
|
||||
TimeSeries,
|
||||
DataQueryError,
|
||||
} from '@grafana/data';
|
||||
import { Scenario, TestDataQuery } from './types';
|
||||
import { getBackendSrv } from 'app/core/services/backend_srv';
|
||||
@@ -67,6 +68,7 @@ export class TestDataDataSource extends DataSourceApi<TestDataQuery> {
|
||||
|
||||
processQueryResult(queries: any, res: any): DataQueryResponse {
|
||||
const data: TestData[] = [];
|
||||
let error: DataQueryError | undefined = undefined;
|
||||
|
||||
for (const query of queries) {
|
||||
const results = res.data.results[query.refId];
|
||||
@@ -81,9 +83,15 @@ export class TestDataDataSource extends DataSourceApi<TestDataQuery> {
|
||||
for (const series of results.series || []) {
|
||||
data.push({ target: series.name, datapoints: series.points, refId: query.refId, tags: series.tags });
|
||||
}
|
||||
|
||||
if (results.error) {
|
||||
error = {
|
||||
message: results.error,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return { data };
|
||||
return { data, error };
|
||||
}
|
||||
|
||||
annotationQuery(options: any) {
|
||||
|
||||
Reference in New Issue
Block a user