mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05: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:
+4
-1
@@ -1,6 +1,7 @@
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { useAsync, useDebounce } from 'react-use';
|
||||
|
||||
import { isFetchError } from '@grafana/runtime';
|
||||
import { Button, Field, Input, Modal } from '@grafana/ui';
|
||||
import { FolderPicker } from 'app/core/components/Select/FolderPicker';
|
||||
|
||||
@@ -36,7 +37,9 @@ export const AddLibraryPanelContents = ({ panel, initialFolderId, onDismiss }: A
|
||||
try {
|
||||
return !(await getLibraryPanelByName(panelName)).some((lp) => lp.folderId === folderId);
|
||||
} catch (err) {
|
||||
err.isHandled = true;
|
||||
if (isFetchError(err)) {
|
||||
err.isHandled = true;
|
||||
}
|
||||
return true;
|
||||
} finally {
|
||||
setWaiting(false);
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useEffect } from 'react';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import useAsyncFn from 'react-use/lib/useAsyncFn';
|
||||
|
||||
import { isFetchError } from '@grafana/runtime';
|
||||
import { notifyApp } from 'app/core/actions';
|
||||
import { PanelModel } from 'app/features/dashboard/state';
|
||||
|
||||
@@ -17,8 +18,11 @@ export const usePanelSave = () => {
|
||||
try {
|
||||
return await saveAndRefreshLibraryPanel(panel, folderId);
|
||||
} catch (err) {
|
||||
err.isHandled = true;
|
||||
throw new Error(err.data.message);
|
||||
if (isFetchError(err)) {
|
||||
err.isHandled = true;
|
||||
throw new Error(err.data.message);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user