diff --git a/src/components/ClientMonitor/LabelPrinterMonitorPanel.tsx b/src/components/ClientMonitor/LabelPrinterMonitorPanel.tsx index eb8b10d..88238a1 100644 --- a/src/components/ClientMonitor/LabelPrinterMonitorPanel.tsx +++ b/src/components/ClientMonitor/LabelPrinterMonitorPanel.tsx @@ -189,6 +189,11 @@ export default function LabelPrinterMonitorPanel({ { method: "POST" }, ); if (checkRes.status === 401 || checkRes.status === 403) return; + if (checkRes.status === 404) { + throw new Error( + "標籤印表機監控 API 未啟用,請重新啟動後端並確認已部署最新版本" + ); + } if (!checkRes.ok) { throw new Error(`check HTTP ${checkRes.status}`); } @@ -197,7 +202,9 @@ export default function LabelPrinterMonitorPanel({ setSummary(checkData.summary ?? null); } catch (e) { console.error("label printer monitor check", e); - setError("無法檢查標籤印表機狀態"); + setError( + e instanceof Error ? e.message : "無法檢查標籤印表機狀態" + ); } finally { setLoading(false); checkInFlightRef.current = false; diff --git a/src/components/ClientMonitor/PrinterMonitorTab.tsx b/src/components/ClientMonitor/PrinterMonitorTab.tsx index a07cfa3..6c2fbb5 100644 --- a/src/components/ClientMonitor/PrinterMonitorTab.tsx +++ b/src/components/ClientMonitor/PrinterMonitorTab.tsx @@ -85,6 +85,11 @@ export default function PrinterMonitorTab({ active, refreshAt = 0 }: Props) { { method: "POST" } ); if (response.status === 401 || response.status === 403) return; + if (response.status === 404) { + throw new Error( + "印表機監控 API 未啟用,請重新啟動後端並確認已部署最新版本" + ); + } if (!response.ok) { throw new Error(`HTTP ${response.status}`); } @@ -94,7 +99,9 @@ export default function PrinterMonitorTab({ active, refreshAt = 0 }: Props) { setSummary(data.summary ?? null); } catch (e) { console.error("printer monitor check", e); - setError("無法檢查印表機連線"); + setError( + e instanceof Error ? e.message : "無法檢查印表機連線" + ); } finally { setLoading(false); inFlightRef.current = false;