Fix: Improve error handling for Glances widgets when host is unreachable (#3657)

---------

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
Matt Sullivan 2024-06-23 17:43:51 +01:00 committed by GitHub
parent ec448d6c41
commit f07d595ed9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 53 additions and 76 deletions

View file

@ -2,7 +2,6 @@ import dynamic from "next/dynamic";
import { useState, useEffect } from "react";
import { useTranslation } from "next-i18next";
import Error from "../components/error";
import Container from "../components/container";
import Block from "../components/block";
@ -31,7 +30,7 @@ export default function Component({ service }) {
});
useEffect(() => {
if (data) {
if (data && !data.error) {
const interfaceData = data.find((item) => item[item.key] === interfaceName);
if (interfaceData) {
@ -52,12 +51,9 @@ export default function Component({ service }) {
}
}, [data, interfaceName, pointsLimit, rxKey, txKey]);
if (error) {
return (
<Container chart={chart}>
<Error error={error} />
</Container>
);
if (error || (data && data.error)) {
const finalError = error || data.error;
return <Container error={finalError} widget={widget} />;
}
if (!data) {