|
7 | 7 | } from '@grafana/data';
|
8 | 8 | import { EditorMode } from '@grafana/plugin-ui';
|
9 | 9 | import { GoogleAuthType } from '@grafana/google-sdk';
|
10 |
| -import { DataSourceWithBackend, getTemplateSrv } from '@grafana/runtime'; |
| 10 | +import { DataSourceWithBackend, getTemplateSrv, HealthCheckError } from '@grafana/runtime'; |
11 | 11 | import { getApiClient } from 'api';
|
12 | 12 | import { uniqueId } from 'lodash';
|
13 | 13 | import { VariableEditor } from './components/VariableEditor';
|
@@ -81,18 +81,22 @@ export class BigQueryDatasource extends DataSourceWithBackend<BigQueryQueryNG, B
|
81 | 81 | async testDatasource() {
|
82 | 82 | const health = await this.callHealthCheck();
|
83 | 83 | if (health.status?.toLowerCase() === 'error') {
|
84 |
| - return { status: 'error', message: health.message, details: health.details }; |
| 84 | + return Promise.reject({ |
| 85 | + status: 'error', |
| 86 | + message: health.message, |
| 87 | + error: new HealthCheckError(health.message, health.details), |
| 88 | + }); |
85 | 89 | }
|
86 | 90 |
|
87 | 91 | const client = await getApiClient(this.id);
|
88 | 92 | try {
|
89 | 93 | await client.getProjects();
|
90 | 94 | } catch (err: any) {
|
91 |
| - return { |
| 95 | + return Promise.reject({ |
92 | 96 | status: 'error',
|
93 | 97 | message: err.data?.message || 'Error connecting to resource manager.',
|
94 |
| - details: err.data?.details, |
95 |
| - }; |
| 98 | + error: new HealthCheckError(err.data?.message, err.data?.details), |
| 99 | + }); |
96 | 100 | }
|
97 | 101 | return {
|
98 | 102 | status: 'OK',
|
|
0 commit comments