Errors: support errors with frame data from backend responses (#24176)

This commit is contained in:
Ryan McKinley
2020-05-04 11:05:04 -07:00
committed by GitHub
parent 9e06f9c402
commit 83683d87f8
11 changed files with 276 additions and 202 deletions
@@ -9,6 +9,7 @@ import {
import { Observable, from } from 'rxjs';
import { config } from '..';
import { getBackendSrv } from '../services';
import { toDataQueryResponse } from './queryResponse';
const ExpressionDatasourceID = '__expr__';
@@ -94,7 +95,11 @@ export class DataSourceWithBackend<
requestId,
})
.then((rsp: any) => {
return this.toDataQueryResponse(rsp?.data);
return toDataQueryResponse(rsp);
})
.catch(err => {
err.isHandled = true; // Avoid extra popup warning
return toDataQueryResponse(err);
});
return from(req);
@@ -109,16 +114,6 @@ export class DataSourceWithBackend<
return query;
}
/**
* This makes the arrow library loading async.
*/
async toDataQueryResponse(rsp: any): Promise<DataQueryResponse> {
const { resultsToDataFrames } = await import(
/* webpackChunkName: "apache-arrow-util" */ '@grafana/data/src/dataframe/ArrowDataFrame'
);
return { data: resultsToDataFrames(rsp) };
}
/**
* Make a GET request to the datasource resource path
*/