mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Check error state more reliably
This commit is contained in:
committed by
Tom Ratcliffe
parent
a0373c66c3
commit
4fb1ac2bec
@@ -2158,10 +2158,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Styles should be written using objects.", "3"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "4"]
|
||||
],
|
||||
"public/app/features/alerting/unified/components/silences/SilencesTable.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"]
|
||||
],
|
||||
"public/app/features/alerting/unified/hooks/useAlertmanagerConfig.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
|
||||
@@ -2,6 +2,7 @@ import { css } from '@emotion/css';
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { dateMath, GrafanaTheme2 } from '@grafana/data';
|
||||
import { isFetchError } from '@grafana/runtime';
|
||||
import { CollapsableSection, Icon, Link, LinkButton, useStyles2, Stack, Alert } from '@grafana/ui';
|
||||
import { useQueryParams } from 'app/core/hooks/useQueryParams';
|
||||
import { alertSilencesApi } from 'app/features/alerting/unified/api/alertSilencesApi';
|
||||
@@ -59,8 +60,7 @@ const SilencesTable = ({ alertManagerSourceName }: Props) => {
|
||||
);
|
||||
|
||||
const mimirLazyInitError =
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(error as any)?.message?.includes('the Alertmanager is not configured') && amFeatures?.lazyConfigInit;
|
||||
isFetchError(error) && error?.message?.includes('the Alertmanager is not configured') && amFeatures?.lazyConfigInit;
|
||||
|
||||
const styles = useStyles2(getStyles);
|
||||
const [queryParams] = useQueryParams();
|
||||
@@ -109,9 +109,8 @@ const SilencesTable = ({ alertManagerSourceName }: Props) => {
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const errMessage = (error as any)?.message || 'Unknown error.';
|
||||
if (isFetchError(error)) {
|
||||
const errMessage = error?.message || 'Unknown error.';
|
||||
return (
|
||||
<Alert severity="error" title="Error loading silences">
|
||||
{errMessage}
|
||||
|
||||
Reference in New Issue
Block a user