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