mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Enable useUnknownInCatchVariables for stricter type checking in catch blocks (#50591)
* wrap a bunch of errors * wrap more things! * fix up some unit tests * wrap more errors * tiny bit of tidy up
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { PluginError, PluginMeta, renderMarkdown } from '@grafana/data';
|
||||
import { getBackendSrv } from '@grafana/runtime';
|
||||
import { getBackendSrv, isFetchError } from '@grafana/runtime';
|
||||
|
||||
import { API_ROOT, GCOM_API_ROOT } from './constants';
|
||||
import { isLocalPluginVisible, isRemotePluginVisible } from './helpers';
|
||||
@@ -45,8 +45,10 @@ async function getRemotePlugin(id: string): Promise<RemotePlugin | undefined> {
|
||||
try {
|
||||
return await getBackendSrv().get(`${GCOM_API_ROOT}/plugins/${id}`, {});
|
||||
} catch (error) {
|
||||
// It can happen that GCOM is not available, in that case we show a limited set of information to the user.
|
||||
error.isHandled = true;
|
||||
if (isFetchError(error)) {
|
||||
// It can happen that GCOM is not available, in that case we show a limited set of information to the user.
|
||||
error.isHandled = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -66,8 +68,10 @@ async function getPluginVersions(id: string, isPublished: boolean): Promise<Vers
|
||||
grafanaDependency: v.grafanaDependency,
|
||||
}));
|
||||
} catch (error) {
|
||||
// It can happen that GCOM is not available, in that case we show a limited set of information to the user.
|
||||
error.isHandled = true;
|
||||
if (isFetchError(error)) {
|
||||
// It can happen that GCOM is not available, in that case we show a limited set of information to the user.
|
||||
error.isHandled = true;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -79,7 +83,9 @@ async function getLocalPluginReadme(id: string): Promise<string> {
|
||||
|
||||
return markdownAsHtml;
|
||||
} catch (error) {
|
||||
error.isHandled = true;
|
||||
if (isFetchError(error)) {
|
||||
error.isHandled = true;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createAction, createAsyncThunk, Update } from '@reduxjs/toolkit';
|
||||
|
||||
import { PanelPlugin } from '@grafana/data';
|
||||
import { getBackendSrv } from '@grafana/runtime';
|
||||
import { getBackendSrv, isFetchError } from '@grafana/runtime';
|
||||
import { importPanelPlugin } from 'app/features/plugins/importPanelPlugin';
|
||||
import { StoreState, ThunkResult } from 'app/types';
|
||||
|
||||
@@ -39,7 +39,9 @@ export const fetchRemotePlugins = createAsyncThunk<RemotePlugin[], void, { rejec
|
||||
try {
|
||||
return await getRemotePlugins();
|
||||
} catch (error) {
|
||||
error.isHandled = true;
|
||||
if (isFetchError(error)) {
|
||||
error.isHandled = true;
|
||||
}
|
||||
return thunkApi.rejectWithValue([]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user