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:
Ashley Harrison
2022-06-15 08:59:29 +01:00
committed by GitHub
parent 2fbe99c1be
commit 803473f479
62 changed files with 364 additions and 177 deletions

View File

@@ -82,7 +82,7 @@ export const validateIntervals = (
getValidIntervals(intervals, dependencies);
return null;
} catch (err) {
return err.message;
return err instanceof Error ? err.message : 'Invalid intervals';
}
};

View File

@@ -6,7 +6,7 @@ import { Subscription } from 'rxjs';
import { FieldConfigSource, GrafanaTheme2 } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
import { locationService } from '@grafana/runtime';
import { isFetchError, locationService } from '@grafana/runtime';
import {
HorizontalGroup,
InlineSwitch,
@@ -163,7 +163,9 @@ export class PanelEditorUnconnected extends PureComponent<Props> {
await saveAndRefreshLibraryPanel(this.props.panel, this.props.dashboard.meta.folderId!);
this.props.notifyApp(createPanelLibrarySuccessNotification('Library panel saved'));
} catch (err) {
this.props.notifyApp(createPanelLibraryErrorNotification(`Error saving library panel: "${err.statusText}"`));
if (isFetchError(err)) {
this.props.notifyApp(createPanelLibraryErrorNotification(`Error saving library panel: "${err.statusText}"`));
}
}
return;
}

View File

@@ -64,7 +64,7 @@ export const SaveDashboardAsForm: React.FC<SaveDashboardAsFormProps> = ({
await validationSrv.validateNewDashboardName(getFormValues().$folder.id, dashboardName);
return true;
} catch (e) {
return e.message;
return e instanceof Error ? e.message : 'Dashboard name is invalid';
}
};