mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-03 14:03:40 +01:00
better error handling
This commit is contained in:
parent
58ceb973d7
commit
f079bb649a
@ -1,6 +1,7 @@
|
|||||||
import Container from "components/services/widget/container";
|
import Container from "components/services/widget/container";
|
||||||
import Block from "components/services/widget/block";
|
import Block from "components/services/widget/block";
|
||||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
|
import { Buffer } from 'buffer';
|
||||||
|
|
||||||
export default function Component({ service }) {
|
export default function Component({ service }) {
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
@ -9,7 +10,13 @@ export default function Component({ service }) {
|
|||||||
const { data: jobStats, error: jobStatsError } = useWidgetAPI(widget, "job_stats");
|
const { data: jobStats, error: jobStatsError } = useWidgetAPI(widget, "job_stats");
|
||||||
|
|
||||||
if (printerStatsError) {
|
if (printerStatsError) {
|
||||||
return <Container service={service} error={printerStatsError} />;
|
let msg
|
||||||
|
msg = JSON.parse(new Buffer.from(printerStatsError.resultData.data).toString());
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="OFFLINE" value={msg.error} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jobStatsError) {
|
if (jobStatsError) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user